From 81d44314e320c4d729a7d55d48614eafa0ef7ffc Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 2 Jul 2024 14:54:54 -0400 Subject: [PATCH] Allow warning exit from jpegtran --- lib/philomena_media/processors/jpeg.ex | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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