[wp-trac] [WordPress Trac] #57975: Uploading iPhone JPG images with EXIF data causes unwanted file modifications.

WordPress Trac noreply at wordpress.org
Fri Mar 24 22:54:17 UTC 2023


#57975: Uploading iPhone JPG images with EXIF data causes unwanted file
modifications.
----------------------------+-----------------------
 Reporter:  hbaumhardt      |       Owner:  (none)
     Type:  defect (bug)    |      Status:  reopened
 Priority:  normal          |   Milestone:
Component:  Filesystem API  |     Version:  6.1.1
 Severity:  normal          |  Resolution:
 Keywords:  close           |     Focuses:
----------------------------+-----------------------
Changes (by azaozz):

 * keywords:   => close


Comment:

 Replying to [comment:2 hbaumhardt]:
 > So WordPress is not able to accept image uploads direct from camera
 phones

 Exactly the opposite :)

 WordPress attempts to make all uploaded images "Internet ready". Images
 uploaded directly from smart phones are generally too big (by file size
 and by pixel dimensions) to be used on the Internet.

 > This should not be happening with `[
 add_filter('big_image_size_threshold', 'return_false'); ]` but it is:
 > Upload: 2582KbJpgImageWithEXIFdata.jpg 2582Kb
 > Result: 2582KbJpgImageWithEXIFdata-rotated.jpg 5171Kb

 That is incorrect. From the example it seems the "Result" image was not
 resized, i.e. it is not Internet ready because the
 `big_image_size_threshold` was disabled. It was rotated as seems the EXIF
 Orientation data indicated it is not oriented correctly.

 The file size depends on the JPEG compression setting and in most cases
 recompressing a photo makes it quite smaller. Not sure why the example
 shows a much larger file size. Generally that would happen if the uploaded
 image was already compressed a lot more, typically with compression
 setting of 50% or less.

 Often photos taken with smart phones are not oriented properly as the
 phone was rotated when the image was taken. The browsers can rotate the
 image in such cases if the EXIF data is present. However not all images
 are viewed in browsers, and the EXIF data is not preserved when image sub-
 sizes are created with GD (this is a limitation of the GD library in PHP).
 To avoid showing incorrectly rotated images (sideways or upside-down)
 WordPress uses the EXIF "Orientation" data (when present) to rotate the
 uploaded image before making the sub-sizes.

 > So it looks like Orientation metadata is MOSTLY (not always) being used
 to refactor the image. Totally unnecessarily as the images start in the
 correct orientation.

 WordPress would always rotate an uploaded photo when the EXIF Orientation
 is not `1` and the image is not "mirrored" (cameras do not produce
 mirrored images).

 Of course if you dislike this behaviour you can use the existing filters
 to disable it. All filters are documented at
 https://developer.wordpress.org/reference/.

 What is the bug that is being reported here?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57975#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list