Change method of convert using stdout, make progressive jpegs

This commit is contained in:
Mark Felder 2020-08-26 15:37:45 +00:00
parent d4d1192341
commit 2c95533ead

View file

@ -27,6 +27,7 @@ defp prepare_resize_args(%{max_width: max_width, max_height: max_height} = optio
quality = options[:quality] || 85 quality = options[:quality] || 85
resize = Enum.join([max_width, "x", max_height, ">"]) resize = Enum.join([max_width, "x", max_height, ">"])
args = [ args = [
"-interlace", "Plane",
"-resize", resize, "-resize", resize,
"-quality", to_string(quality) "-quality", to_string(quality)
] ]
@ -36,7 +37,7 @@ defp prepare_resize_args(%{max_width: max_width, max_height: max_height} = optio
defp prepare_resize_args(_), do: {:error, :missing_options} defp prepare_resize_args(_), do: {:error, :missing_options}
defp run_fifo(fifo_path, env, executable, args) do defp run_fifo(fifo_path, env, executable, args) do
args = List.flatten([fifo_path, args, "jpg:fd:1"]) args = List.flatten([fifo_path, args, "jpg:-"])
pid = Port.open({:spawn_executable, executable}, [:use_stdio, :stream, :exit_status, :binary, args: args]) pid = Port.open({:spawn_executable, executable}, [:use_stdio, :stream, :exit_status, :binary, args: args])
fifo = Port.open(to_charlist(fifo_path), [:eof, :binary, :stream, :out]) fifo = Port.open(to_charlist(fifo_path), [:eof, :binary, :stream, :out])
true = Port.command(fifo, env.body) true = Port.command(fifo, env.body)