Compensate for Brandfolder image ingest issue with rotated images

Created on 7 August 2023, over 1 year ago
Updated 5 April 2024, 7 months ago

Problem/Motivation

Certain images from certain cameras/devices seem to be processed by Brandfolder in a way that results in the image metadata having inverted values for width and height. This results in those images appearing squished/distorted when processed by Drupal image styles.

Here is a real example:
CDN URL for attachment (displays in portrait orientation):

Excerpt from the API response for an attachment fetch, showing width and height values indicating a landscape orientation/aspect ratio, whereas the image is displayed in Brandfolder and via CDN URLs in portrait orientation. Note the "Rotate 90 CW" metadata directive.

CDN URL for a Drupal image style derivative of that same attachment, demonstrating the negative impact of the width and height values being transposed:

Proposed resolution

  1. Consider attempting to detect rotation metadata when processing a given BF attachment in Drupal for the first time, and allow that to inform width and height values saved in Drupal, and/or:
  2. Give Drupal admins a mechanism to manually fix existing media entities suffering from this issue.

User interface changes

  • If implementing the second solution, media entity edit form for BF Image entities will have new elements showing width and height values and an option to transpose them.

API changes

None.

Data model changes

None.

✨ Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States ndewhurst USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ndewhurst
  • πŸ‡ΊπŸ‡ΈUnited States ndewhurst USA
  • πŸ‡ΊπŸ‡ΈUnited States ndewhurst USA
  • πŸ‡ΊπŸ‡ΈUnited States azinck

    I haven't tested this with Brandfolder, but I'd expect this module to solve your problems: https://www.drupal.org/project/exif_orientation β†’

  • πŸ‡ΊπŸ‡ΈUnited States ndewhurst USA

    Hi azinck, thanks for the suggestion. That module addresses the same type of issue but wouldn't help in our case. The symptom we're dealing with here manifests after Brandfolder has already processed a user-uploaded image file on their end, and the metadata that comes through from their API is inconsistent. The perceived orientation of the Brandfolder-hosted image is correct, but the width and height values provided by the API are interposed sometimes. I looked at the EXIF data exif_orientation reads, but didn't find a similar pattern with what comes over the wire from Brandfolder or exists within the image files themselves. In any case, while I could add support for the native PHP exif read on Brandfolder "files," supporting the image rotate() op as it's used by exif_orientation would be a bit outside the current scope/paradigm in terms of how BF images are transformed upon delivery / per image style.

  • Status changed to Fixed 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States ndewhurst USA

    Upon testing/review, we decided the safest/most feasible option was (2). BF Image media entities now have this option on the media edit form:

    This is available and working with Drupal 10 in 5.0.x-dev.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024