Currently the color module creates an empty image canvas without any background color, which means GD by default creates an black image. There is no way to get this image back to a transparent one or extracting slices with transparent background, they all end up being black. I propose to add some background color (with alpha support), allow users to define some background.png (in addition to base.png, could be transparent) or some other feature to allow transparent images.
We currently implemented a "color_alpha_patch"-module which changes all images to being transparent by default. I uploaded the "color_alpha_patch.module" as example. The module was needed as we wantet to create sliding door buttons including a transparent background and semi-transparent drop shadow (the buttons should be reuseable on different backgrounds).
I'm pretty sure this can be done in a better way inside core.
| Comment | File | Size | Author |
|---|---|---|---|
| color_alpha_patch.zip | 3.67 KB | ddanier |
Comments
Comment #1
ddanier commentedForgot to mention how the module works:
It basically add a second submit-function to the theme settings form. The new submit-function is a copy of the color modules submit function. I replaced _color_render_images() with a version using a transparent canvas for all image operations. For this to work we need to fill the image with a transparent color while imagealphablending if off. In addition we need to enable imagesavealpha to make sure PNGs are saved including alpha information. This needs to be done for the main canvas and every slice we want to extract.
Currently the module leaves the original color submit function in place, so storing the color information is done twice.
Comment #2
markhalliwellDup of #850512: Enable Color module to create recolorable png24 Images with transparent background which should get fixed in 8.x and then backported to 7.x.