EXIF orientation is not taken into account in uploaded images

Bug #1792039 reported by Sean Manning
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Libravatar (obsolete)
Confirmed
Medium
François Marier

Bug Description

When I upload images like this coin, making sure that they are oriented so that the face is looking left or right, they appear rotated with the face looking upwards. I do not see any way to rotate them in libravatar, just to crop them. Cropping the original, larger image so it is taller than it is wide or wider than it is tall does not help.

Tags: jpeg upload
Revision history for this message
Sean Manning (antiquarian) wrote :
Revision history for this message
François Marier (fmarier) wrote :

I suspect the problem is that the includes a mandatory rotation in the Exif data and that jpegoptim strips it out:

$ file before.jpg
before.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, Exif Standard: [TIFF image data, little-endian, direntries=11, manufacturer=Panasonic, model=DMC-SZ10, orientation=upper-right, xresolution=166, yresolution=174, resolutionunit=2, software=Shotwell 0.22.0], baseline, precision 8, 2302x2121, frames 3

$ cp before.jpg after.jpg
$ jpegoptim --strip-all after.jpg
after.jpg 2302x2121 24bit N Exif XMP JFIF [OK] 740417 --> 728927 bytes (1.55%), optimized.

$ file after.jpg
after.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 2302x2121, frames 3

Changed in libravatar:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → François Marier (fmarier)
Revision history for this message
François Marier (fmarier) wrote :

Actually the problem comes before jpegoptim enters the picture. The images served out of /uploaded/ are not rotated properly on the "Crop photo" page and the browser will only apply the EXIF rotation if the image is navigated to directly.

Maybe we need to run exiftran (https://www.kraxel.org/blog/linux/fbida/) first on all of the uploaded images to ensure that the orientation is fixed up before crop happens.

summary: - Image Automatically Rotated Wrong-Way Up
+ EXIF orientation is not taken into account in uploaded images
Revision history for this message
François Marier (fmarier) wrote :

Here's the output of:

    exiftran -o rotated.jpg -a P1000927_tmp.JPG

Changed in libravatar:
status: Confirmed → Fix Committed
Revision history for this message
François Marier (fmarier) wrote :
Changed in libravatar:
status: Fix Committed → Triaged
Revision history for this message
François Marier (fmarier) wrote :

The problem in my fix is that I applied it to PNG files instead of JPEG.

tags: added: jpeg
Changed in libravatar:
status: Triaged → Confirmed
Revision history for this message
François Marier (fmarier) wrote :

exiftran is now running on JPG files instead of PNG ones, but it still doesn't rotate the file. Perhaps it needs to be applied before cropping instead of afterwards.

Ideally it should be applied on the uploaded file directly since we probably want to see the rotated photo while cropping.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.