diff --git a/lib/philomena_media/processors/jpeg.ex b/lib/philomena_media/processors/jpeg.ex index 6e9f728e..60444257 100644 --- a/lib/philomena_media/processors/jpeg.ex +++ b/lib/philomena_media/processors/jpeg.ex @@ -8,6 +8,9 @@ defmodule PhilomenaMedia.Processors.Jpeg do @behaviour Processor + @exit_success 0 + @exit_warning 2 + @spec versions(Processors.version_list()) :: [Processors.version_filename()] def versions(sizes) do Enum.map(sizes, fn {name, _} -> "#{name}.jpg" end) @@ -68,7 +71,7 @@ defmodule PhilomenaMedia.Processors.Jpeg do _ -> # Transmux only: Strip EXIF without touching orientation - {_output, 0} = System.cmd("jpegtran", ["-copy", "none", "-outfile", stripped, file]) + validate_return(System.cmd("jpegtran", ["-copy", "none", "-outfile", stripped, file])) end stripped @@ -77,7 +80,7 @@ defmodule PhilomenaMedia.Processors.Jpeg do defp optimize(file) do optimized = Briefly.create!(extname: ".jpg") - {_output, 0} = System.cmd("jpegtran", ["-optimize", "-outfile", optimized, file]) + validate_return(System.cmd("jpegtran", ["-optimize", "-outfile", optimized, file])) optimized end @@ -108,4 +111,8 @@ defmodule PhilomenaMedia.Processors.Jpeg do defp srgb_profile do Path.join(File.cwd!(), "priv/icc/sRGB.icc") end + + defp validate_return({_output, ret}) when ret in [@exit_success, @exit_warning] do + :ok + end end