Scale-and-crop is vulnerable to bad aspect ratios

Created on 18 December 2017, about 7 years ago
Updated 1 March 2023, almost 2 years ago

The scale-and-crop filter upscales before it crops images. This is bad if the aspect ratios of the input and output are strongly divergent, as it leads to a big intermediate image.

Example: If I scale-crop to 800x600, and upload a 1000x1 placeholder image, Drupal will attempt to create a 800000x600 image before cropping to 800x600 - this is 480 megapixels, which easily exceeds server memory limits.

(To avoid weird rounding problems or distortions in very small images, the best solution might be to crop the maximum dimension to MAX=CEIL(target_ratio*MIN) first, then scale, and finally crop the maximum dimension again to get the exact aspect ratio.)

🐛 Bug report
Status

Needs review

Version

10.1

Component
Image system 

Last updated 1 day ago

Created by

🇨🇭Switzerland cburschka

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024