Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Earlier versions did it right. Now the canvas action with a transparent setting returns a white background...
Comments
Comment #1
JordanMagnuson CreditAttribution: JordanMagnuson commentedI know this is an old issue, but as it's still open... is it possible to create a transparent canvas?
In the current 7.x version, I don't see any transparent "option" anywhere....
Comment #2
fietserwinLeaving the "HEX" field empty, will give you a transparent background (at least in the D7 version). Don't forget to convert format to PNG or GIF though.
I will write a TODO about the naming and/or expalnation of colorfields in general, and this field in special.
Comment #3
ShaneOnABike CreditAttribution: ShaneOnABike commentedOkay I can see how to make it transparent but it doesn't seem to work... unless I'm missing something.
Created a style with
* Change file format Convert to: png
* Scale width 296
* Crop 296x500
* Define canvas left: right: top: bottom: Transparent under image
I end up with a background of black not transparent in the sample? Am I missing something...
Comment #4
fietserwinCan you post the style using the export image style option of the image_styles_admin sub module?
Comment #5
fietserwinOK, tried to reproduce what you experienced.
The black part comes from the crop effect that enlarges the image (unless it is extremely portrait). When making an image larger while cropping, a canvas will automatically be created. Depending on the toolkit in use it will be either black (GD) or transparent (Imagemagick).
After the crop effect you define a canvas that I think has the same width and height as the current image (left: right: top: bottom:), so nothing will change as it will be placed under the image (with its black background).
Note 1: what I don't get, looking at the GD code in Drupal core, is why it ends up to be black and not transparent, but that probably has to do with the blending or saving mode.
Note 2: If you think that the GD cropping is not as expected, you should open an issue in the Drupal core issue queue.
Comment #6
dman CreditAttribution: dman commentedIf you skipped the 'crop' altogether and went straight to define_canvas:exact size ... I'd expect that to do it.
define_canvas will crop as a side-effect if necessary. It was built to deal with things like this that core+GD didn't do well.
Yeah, in GD, 'undefined' area generally means solid black, even when you have alpha support. Pretty ugly. Though in some cases I have seen random binary squiggles there as it it was pulled straight out of uninitialized memory.
Comment #7
noopal CreditAttribution: noopal commented