Add new feature 'Allow Upcropping' to image crop effects

Created on 11 December 2007, over 16 years ago
Updated 13 February 2024, 7 months ago

This is my first attempt at submitting a patch, so please go easy on me. I have noticed many posts from people using imagecache that would like to avoid having black backgrounds on cropped images. One solution is to allow the scaling function to upscale images, but in my situation, I would just rather have the crop action not perform the crop at all if the image is smaller than the size to be cropped too.

The drawback here is that you can't enforce a Standard size for images across the board - but what can you do when your users upload low resolution images? I say you should just let them be low resolution.

Here is what the patch does, it is pretty simple addition on line 199:

        case 'crop':
		 // Patch to ensure images dont get cropped to a larger size if they are smaller than the crop size, otherwise they will get a black background
          if ($action['data']['width'] > $size[0]) {
          	  $action['data']['width'] = $size[0];
          	  $action['data']['xoffset'] = 0;
          }
          if ($action['data']['height'] > $size[1]) {
          	$action['data']['height'] = $size[1];
          	$action['data']['yoffset'] = 0;
          }
          ....
✨ Feature request
Status

Needs work

Version

9.5

Component
Image systemΒ  β†’

Last updated about 11 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States gravit

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡ͺπŸ‡ΈSpain candelas

    Good ideas are good ideas.
    I would love to have this one for Drupal 11 and 10.
    Do you know if any module has implemented? I don't find any.

Production build 0.71.5 2024