Drupal - Change image background colour when cropping

You could try with ImageCache Actions module. Enable Imagecache Canvas Actions module that is shipped with ImageCache Actions and than change your style effects order to:

  1. Scale
  2. Define canvas (set your color and scale dimensions)
  3. Crop

For Drupal 8 you'll use the Image Effects module. This will provide additional options for your Drupal "image styles". The most effective way I have found to do this is to create an image style with the following effects:

  • Scale either a width or height.
  • Set canvas - Exact size. Give it the width and height of the final image style and provide a background image. It defaults to transparent so uncheck that and provide your own colour.
  • Crop to size (the width and height you applied to the canvas above).

Image atached of an example with a red canvas enter image description here

Tags:

Media

7