Opened 3 years ago
Last modified 5 months ago
#14459 reviewing enhancement
Rotate Full Size Images on Upload
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Upload | Version: | 3.0 |
| Severity: | normal | Keywords: | needs-patch westi-like mobile |
| Cc: | merty92@…, ercoli@… |
Description
It may be worth a revisit to #7042. Some mobile devices that use WordPress for Android are not capturing images in the correct orientation, instead they are writing the EXIF orientation to the image instead (which is a standard method these days). In wp-android and other external clients that offer full size image upload, these images will not be rotated correctly upon upload.
Since most mobile users are on the go with no access to the wp-admin area to rotate the images themselves, it would work best if the image was rotated for them automatically.
Hopefully there's a solution that wouldn't strip the EXIF data, some way to copy the EXIF data before rotating, then save it back again?
Change History (22)
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
comment:3
mrroundhill — 2 years ago
- Keywords mobile added
There was an older ticket about this (can't find it at the moment) that had a patch too. Think we didn't do it at the end as many users upload images directly from their cameras and rotating a 10-12 megapixel image was causing PHP to run out of memory.
Related: #11536
Suggestion: Since there is compatibility issues with image rotation, maybe it's worth taking a look at the various functionality we need for image handling and write a wrapper class or two that works based on what support is offered on the host, as well as handling cases where available memory is low and such. Give the most functionality possible given the available functions.
- Keywords westi-like 3.4-early added
We should revisit this because it is becoming more and more common for people to want to upload and post quickly without having to manually fix the rotation of images.
Rotating the image is easy enough, but I can't find any way to do this in PHP and keep the EXIF data in the resulting file. So the original unmodified file would have to be saved as well.
Unless I'm missing something.
Unless I'm missing something.
Unfortunately, IIRC, GD doesnt support EXIF preservation at all. That's one of the advantages of ImageMagik. Unless of course there's a PHP library to add exif back into the images afterwards.
Side note: The new image_resize checkbox will cause the code to strip the EXIF data as well, before it gets read in as the attachment metadata.
comment:10
in reply to:
↑ 9
azaozz — 20 months ago
Replying to Otto42:
The resizing is actually done with js when supported (most cases) which preserves exif data.
comment:11
Otto42 — 20 months ago
True, but if the resize isn't done on the client side (not supported case), then it's done in wp_handle_upload, and exif will be lost there.
comment:12
follow-up:
↓ 13
azaozz — 20 months ago
Currently it's supported for all runtimes that we use (HTML5, Flash, Silverlight) except in Safari and Opera when using HTML5 http://www.plupload.com/. Alternatively we can disable resizing in php completely and allow it only when supported on the client side.
comment:13
in reply to:
↑ 12
westi — 17 months ago
Replying to azaozz:
Currently it's supported for all runtimes that we use (HTML5, Flash, Silverlight) except in Safari and Opera when using HTML5 http://www.plupload.com/. Alternatively we can disable resizing in php completely and allow it only when supported on the client side.
This doesn't really help when images are uploaded not using the uploader - e.g. XML-RPC, or a post-by-email solution - I don't think we should expect all clients to do the rotation for us.
Having it work only a %age of the time is confusing.
comment:14
dd32 — 11 months ago
- Milestone changed from Future Release to 3.5
Closed #21006 as a duplicate, pulling this into the 3.5 timeline for consideration as that's where the other ticket was.
comment:15
merty — 11 months ago
- Cc merty92@… added
comment:16
azaozz — 11 months ago
The best way to handle this in PHP is with jpegtran and exiftool. Both are command line tools available for all platforms, the EXIF is fully preserved (EXIF orientation is reset with exiftool) and the quality of the JPEG is preserved 100%. However using them would also require PHP's exec() to be enabled.
Another option is to rotate only the resized images leaving the original as-is (flikr does this). Perhaps this could be done only for larger JPEG images like photos, larger than the max size.
Yet another option would be to rotate the images on display. In most current browsers this is possible now but will be hard to implement in core.
comment:17
azaozz — 11 months ago
- Keywords mobile 3.4-early removed
- Owner set to azaozz
- Status changed from new to reviewing
comment:18
nacin — 7 months ago
- Milestone changed from 3.5 to Future Release
This requires jpegtran, exiftool, etc. Now that we have WP_Image_Editor, we can do this in a future release.
comment:19
daniloercoli — 7 months ago
- Cc ercoli@… added
- Keywords mobile added
comment:20
daniloercoli — 7 months ago
See also #12493.
comment:21
follow-up:
↓ 22
webmystery — 5 months ago
It would be nice to fully recognize exif rotation. When a user uploads an exif rotated image the correct image sizes are not created and all of my automatic placement of the featured image /gallery images are displayed at full size, etc... Took me a bit of head scratching to figure out why one image in a particular post was displaying full-size, especially as I was not the one who uploaded it and the user who reported the problem neglected to tell me that hey had to rotate the image after the upload. Regenerating the image sizes didn't work either. I had to re-save the image in photoshop and re-upload it to fix the problem. This would have been impossible for the less geeky to figure out.
comment:22
in reply to:
↑ 21
SergeyBiryukov — 5 months ago
Replying to webmystery:
the correct image sizes are not created and all of my automatic placement of the featured image /gallery images are displayed at full size, etc...

+1, the EXIF Orientation tag is not respected by the image handler. This happens to iPhone images that are uploaded through the media uploader.
Documentation on the tag and the values therein can be found here:
http://sylvana.net/jpegcrop/exif_orientation.html