mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
fixes #74: only reencode the image when there is no choice to fix the orientation
This commit is contained in:
parent
be520b1d7c
commit
d82bb4f33f
1 changed files with 11 additions and 1 deletions
|
@ -26,7 +26,17 @@ defmodule Philomena.Processors.Jpeg do
|
|||
defp strip(file) do
|
||||
stripped = Briefly.create!(extname: ".jpg")
|
||||
|
||||
{_output, 0} = System.cmd("convert", [file, "-auto-orient", "-strip", stripped])
|
||||
# ImageMagick always reencodes the image, resulting in quality loss, so
|
||||
# be more clever
|
||||
case System.cmd("identify", ["-format", "%[orientation]", file]) do
|
||||
{"Undefined", 0} ->
|
||||
# Strip EXIF without touching orientation
|
||||
{_output, 0} = System.cmd("jpegtran", ["-copy", "none", "-outfile", stripped, file])
|
||||
|
||||
{_output, 0} ->
|
||||
# Strip EXIF and reorient image
|
||||
{_output, 0} = System.cmd("convert", [file, "-auto-orient", "-strip", stripped])
|
||||
end
|
||||
|
||||
stripped
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue