Earlier versions did it right. Now the canvas action with a transparent setting returns a white background...

Comments

JordanMagnuson’s picture

Title: Transparent canvas return white canvas. » Transparent canvas?
Version: 6.x-2.x-dev » 7.x-1.x-dev

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

fietserwin’s picture

Status: Active » Closed (works as designed)

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

ShaneOnABike’s picture

Status: Closed (works as designed) » Needs work

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

fietserwin’s picture

Can you post the style using the export image style option of the image_styles_admin sub module?

fietserwin’s picture

Status: Needs work » Closed (works as designed)

OK, 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.

dman’s picture

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

noopal’s picture

Issue summary: View changes