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.
ImageAPI GD2 generates always black background color in spite of the crop background setting. Tested with GD Library bundled (2.0.34 compatible).
Comment | File | Size | Author |
---|---|---|---|
#18 | 422836.patch | 1.49 KB | p.brouwers |
#18 | tux.gif | 15.44 KB | p.brouwers |
#18 | tux_without_patch.gif | 6.22 KB | p.brouwers |
#18 | tux_with_patch.gif | 5.42 KB | p.brouwers |
#4 | imageapi_422836.patch | 1.42 KB | drewish |
Comments
Comment #1
drewish CreditAttribution: drewish commentedwhich type of image are you rotating? and is there transparency?
Comment #2
manop CreditAttribution: manop commentedI got the same problem on my JPG images. I used "crop" and "rotate." It added black background to me ignoring my configs.
I'm using ImageAPI 6.x-1.5 and ImageCache 6.x-2.0-beta8
Comment #3
psynaptic CreditAttribution: psynaptic commentedSame here:
I've set the Crop background on admin/settings/imageapi/config to FFFFFF and it's still resulting in black bars.
I'm using 8-bit png images with no transparency.
The only place I can see
imageapi_crop_background
is as the form key and in the default value:variable_get('imageapi_crop_background', '')
. Where should this be used?Comment #4
drewish CreditAttribution: drewish commentedthere's actually two bugs. image api has an incorrect parameter name on imageapi_gd_image_rotate() and then imagecache has some issues passing the background color.
the imageapi_crop_background variable that psynaptic points out needs to be removed since it's old cruff.
the attached patch takes care of the imageapi side. i'll open an imagecache issue for the rest.
Comment #5
drewish CreditAttribution: drewish commentedCommitted to DRUPAL-5 and DRUPAL-6--1.
Comment #6
dergachev CreditAttribution: dergachev commentedYour patch takes care of the rotate case, but what about the crop case?
When you crop an image to be bigger than it's current size, black padding will appear.
We need this to be transparent or white.
Comment #7
drewish CreditAttribution: drewish commentedthat's a good point. but since imageapi is in core in 7 i think we should open this as a new core issue and get the fix in there and then backport into imageapi.
Comment #8
dergachev CreditAttribution: dergachev commentedUpdate: the following hack gets rid of 1 of the 2 black bars that appear.
Inspired by the following comment here: http://ca2.php.net/imagecreatetruecolor
Comment #9
drewish CreditAttribution: drewish commentedI just opened #437702: Separate background color and transparency options, add them to crops that enlarge the canvas so lets take it up over there then open a new issue to backport the fix here.
Comment #10
kheops CreditAttribution: kheops commentedHi,
I don't know if it helps but I'm using ImageAPI 6.x-1.3 and ImageCache 6.x-2.0-beta8 and when I crop with oversize, it properly uses the background color I've setup in Administer>Site Configuration>ImageAPI / Configure
Since ImageAPI 6.x-1.4 and up to 1.6, it doesn't work anymore (always uses black) so I reverted to 1.3
Also I think it's since 1.6, but the "Crop Background" color setup is not here anymore?
Comment #12
drewish CreditAttribution: drewish commented#437702: Separate background color and transparency options, add them to crops that enlarge the canvas is tricky... i need to rope dman into helping me fix it.
Comment #13
jrust CreditAttribution: jrust commentedThis was a beast for me as well, and I finally figured out a hack to get rid of the black bar on both sides, using the idea from comment #8, while waiting for it be backported:
Comment #14
drewish CreditAttribution: drewish commentedthat seems illogical. so you fill the cloned image, then allocate a new image, then copy over it?
Comment #15
jrust CreditAttribution: jrust commentedIt's not pretty, but it was the only way I could find to get rid of the black bar that gets created from the crop. You would think that filling the cloned image would get rid of both black bars, but it only gets rid of the one on the left, hence the need for the second copy. Go figure...
Comment #16
p.brouwers CreditAttribution: p.brouwers commentedHad a similar issue that a background from a gif image would be displayed as purple instead of white.
With ImageAPI 6.x-1.6 it showed a partially white background with black sidebars.
Using patch in #13, the black sidebars went away.
Note that the left sidebar is white and not transparent! The right sidebar is transparent.
Don't know why it shows a partially white background with purple spots, propably because of some loss of quality/colors from gif to png?
Comment #17
p.brouwers CreditAttribution: p.brouwers commentedJust checked with ImageAPI 6x-1.5 again with ImageCache 2.0-beta10
Setting nothing for background in settings for ImageAPI resulted in a better result than using ImageAPI 6.x-1.6 + ImageCache 2.0-beta10 + patch #13.
The image still had a partially white background with purple spots but now the left AND right sidebar were transparent.
Hope this helps.
Comment #18
p.brouwers CreditAttribution: p.brouwers commentedHad another go at this.
Using tux.gif and an image style of Scale and crop 150x150 I get a strange background. See tux_without_patch.gif
Almost have a patch working for gifs, it's just displaying a strange glow it shouldn't.
See tux_with_patch.gif for the final result.
Comment #19
momper CreditAttribution: momper commentedsubscribe