alias Pleroma.HTTP
- @tmp_base "/tmp/pleroma-media_preview-pipe"
+ require Logger
+
+ def missing_dependencies do
+ Enum.reduce([imagemagick: "convert", ffmpeg: "ffmpeg"], [], fn {sym, executable}, acc ->
+ if Pleroma.Utils.command_available?(executable) do
+ acc
+ else
+ [sym | acc]
+ end
+ end)
+ end
def image_resize(url, options) do
with executable when is_binary(executable) <- System.find_executable("convert"),
defp prepare_image_resize_args(_), do: {:error, :missing_options}
+ # Note: video thumbnail is intentionally not resized (always has original dimensions)
def video_framegrab(url) do
with executable when is_binary(executable) <- System.find_executable("ffmpeg"),
{:ok, env} <- HTTP.get(url, [], pool: :media),
end
defp mkfifo do
- path = "#{@tmp_base}#{to_charlist(:erlang.phash2(self()))}"
+ path = Path.join(System.tmp_dir!(), "pleroma-media-preview-pipe-#{Ecto.UUID.generate()}")
case System.cmd("mkfifo", [path]) do
{_, 0} ->