+ @tmp_base "/tmp/pleroma-media_preview-pipe"
+
+ def image_resize(url, options) do
+ with executable when is_binary(executable) <- System.find_executable("convert"),
+ {:ok, args} <- prepare_resize_args(options),
+ url = Pleroma.Web.MediaProxy.url(url),
+ {:ok, env} <- Pleroma.HTTP.get(url),
+ {:ok, fifo_path} <- mkfifo()
+ do
+ run_fifo(fifo_path, env, executable, args)
+ else
+ nil -> {:error, {:convert, :command_not_found}}
+ {:error, _} = error -> error
+ end
+ end
+
+ defp prepare_resize_args(%{max_width: max_width, max_height: max_height} = options) do