Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291866

Scale-and-crop is vulnerable to bad aspect ratios

$
0
0

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.)


Viewing all articles
Browse latest Browse all 291866

Trending Articles