[wp-trac] [WordPress Trac] #14459: Rotate Full Size Images on Upload
WordPress Trac
noreply at wordpress.org
Wed Nov 25 23:57:55 UTC 2015
#14459: Rotate Full Size Images on Upload
-------------------------------------------+-----------------------------
Reporter: mrroundhill | Owner: azaozz
Type: enhancement | Status: reviewing
Priority: normal | Milestone: Future Release
Component: Upload | Version: 3.0
Severity: normal | Resolution:
Keywords: needs-patch westi-like mobile | Focuses:
-------------------------------------------+-----------------------------
Comment (by n7studios):
Patch:
https://gist.github.com/n7studios/6a764d46bc1d515ba406
I encountered this problem today, and built a small WordPress Plugin to
resolve it which:
1. Checks for the EXIF orientation flag, to see if the image needs
rotating,
2. Rotates the image, if required,
3. Writes the EXIF and IPTC data from the original image to the modified,
rotated version
4. Sets the EXIF orientation flag to 1, to prevent applications which read
the flag from rotating the image (which would result in over rotation)
I appreciate there's still a lot of work to do, namely:
1. Submitting this as an actual patch for WordPress core,
2. Using the WP Filesystem for ovewriting the image file vs. fopen/fwrite
wrappers
3. I'm a bit dubious about line 140, as I think it'd potentially replace
any 3, 6 or 8 value with 1 (potentially breaking other EXIF metadata -
although in my tests, this didn't happen) - I struggled with hexadecimals:
{{{#!php
$exif_data = str_replace( chr( dechex( $original_orientation ) ) , chr(
0x1 ), $exif_data );
}}}
This doesn't require any particular PHP extensions / libraries, and most
of the code is inspired by this ticket or submissions on php.net, which
I've tried to credit where applicable. The main thing is that EXIF / IPTC
data is retained - this is typically lost when using GD to edit an image.
Would be great to get some thoughts / feedback and see how this can be
improved before submitting as a patch.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/14459#comment:34>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list