Change to using heic-convert which is more common than mogrify supporting these files
This commit is contained in:
parent
9e0e2fb6b4
commit
daba3b8522
@ -163,7 +163,7 @@ defmodule Pleroma.ApplicationRequirements do
|
||||
check_filter(Pleroma.Upload.Filters.Exiftool, "exiftool"),
|
||||
check_filter(Pleroma.Upload.Filters.Mogrify, "mogrify"),
|
||||
check_filter(Pleroma.Upload.Filters.Mogrifun, "mogrify"),
|
||||
check_filter(Pleroma.Upload.Filters.HeifToJpeg, "mogrify")
|
||||
check_filter(Pleroma.Upload.Filters.HeifToJpeg, "heif-convert")
|
||||
]
|
||||
|
||||
preview_proxy_commands_status =
|
||||
|
@ -29,20 +29,18 @@ defmodule Pleroma.Upload.Filter.HeifToJpeg do
|
||||
def filter(_), do: {:ok, :noop}
|
||||
|
||||
defp convert(tempfile) do
|
||||
# cannot save in place when changing format, so we have to use a tmp file
|
||||
# https://github.com/route/mogrify/issues/77
|
||||
# also need a valid extension or it gets confused
|
||||
|
||||
with_extension = tempfile <> ".heic"
|
||||
jpeg = tempfile <> ".jpg"
|
||||
|
||||
File.rename!(tempfile, with_extension)
|
||||
|
||||
%{path: converted} =
|
||||
with_extension
|
||||
|> Mogrify.open()
|
||||
|> Mogrify.format("jpg")
|
||||
|> Mogrify.save()
|
||||
convert_cmd =
|
||||
"heif-convert #{with_extension} #{jpeg}"
|
||||
|> String.to_charlist()
|
||||
|
||||
:os.cmd(convert_cmd)
|
||||
|
||||
File.rm!(with_extension)
|
||||
File.rename!(converted, tempfile)
|
||||
File.rename!(jpeg, tempfile)
|
||||
end
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ defmodule Pleroma.Upload.Filter.HeifToJpegTest do
|
||||
alias Pleroma.Upload.Filter
|
||||
|
||||
test "apply HeicToJpeg filter" do
|
||||
assert Pleroma.Utils.command_available?("mogrify")
|
||||
assert Pleroma.Utils.command_available?("heif-convert")
|
||||
|
||||
File.cp!(
|
||||
"test/fixtures/image.heic",
|
||||
|
Loading…
Reference in New Issue
Block a user