craftcms / craftcms/cms

EXIF rotation data is stripped even when `preserveExifData` is true

Open
#6,947 4 comments 0 reactions 1 assignee View on GitHub

@andris-sevcenko is already working on this.

Since Oct 2, 2020.

bug
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

Description

When an image is uploaded with EXIF rotation meta it is always set to \Imagick::ORIENTATION_UNDEFINED even when preserveExifData is true

Steps to reproduce
  1. Set preserveExifData to true
  2. Upload an image containing EXIF rotation meta
  3. Download the image from its asset volume and check the EXIF data. Rotation will be set to Unknown (0)
Additional info

Offending line is here:

https://github.com/craftcms/cms/blob/14f0fd652b7a99820f804ba6c0a0db762bf26206/src/services/Images.php#L394

Which sets to unknown, but the check to see whether the EXIF data should be preserved is inside ImageHelper::cleanExifDataFromImagickImage on the following line. The image is then resaved with the unknown rotation regardless of any settings.

This is also true if the image has been rotated by rotateImagesOnUploadByExifData although in that scenario the broken rotation meta doesn't cause any issues.

  • Craft version: 3.5.6
  • PHP version: 7.4
  • Plugins & versions: ImageMagick

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.