php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58996 Random black background on transparent image
Submitted: 2009-12-17 09:25 UTC Modified: 2010-05-05 08:59 UTC
From: loranger at free dot fr Assigned:
Status: Closed Package: imagick (PECL)
PHP Version: 5.2.10 OS: Ubuntu Karmic Koala
Private report: No CVE-ID: None
 [2009-12-17 09:25 UTC] loranger at free dot fr
Description:
------------
Very often transparent color is replaced by black or another flat color (dark green for a grey shape, yellow for a white shape, etc...)

It didn't used to do it before. I think a system update add this bug, but I don't know which one.
I had the opportunity to install a brand new Karmic Koala from scratch on another server than mine. I did install php5-imagick (2.1.1RC1-1build2) which uses ImageMagick 6.5.1.
The result is the same : Very often transparent images have black background.
I did uninstall php5-imagick and built a 2.3.0 from pecl sources but the bug remains the same.

I use imagick for few monthes now, including in production environments and I'm quite disapointed with this weird bug.

Reproduce code:
---------------
$im = new Imagick( ?picture.jpg? );
$im->setImageFormat(?png?);
$im->rotateImage( new ImagickPixel(?transparent?), rand(-8, 8) );
header( ?Content-Type: image/?.$im->getImageFormat() );
die( $im );

Expected result:
----------------
rotated image on transparent background

Actual result:
--------------
rotated image on black background... But sometimes it works and display the transparent background

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-17 13:16 UTC] mkoppanen@php.net
Can you try $im->setImageMatte(true); after setting image format to png?
 [2009-12-17 16:08 UTC] loranger at free dot fr
I tried and believed it did the tricks, but the black background came back later. And disappeared again. It's hmmm random.
I can refresh thirty times without any problem and the get four black background again.
It seems the more the image is manipulated (circle, compositeImage, etc...) the more the bug occur and of course saveImage has the same behaviour.
 [2009-12-17 16:35 UTC] mkoppanen@php.net
Does this happen with newer imagemagick / imagick as well? At least the Imagick version you have looks pretty ancient.
 [2009-12-17 20:05 UTC] loranger at free dot fr
I just tried with imagick-3.0.0b1 and it happen too.
I didn't try with a newer imagemagick version because I don't know how to build a working version without messing up my ubuntu.
Anyway i've tried a bunch of convert picture.jpg -rotate -x picture.png but it doesn't seems to bug
 [2009-12-18 06:07 UTC] loranger at free dot fr
The two servers I tested are almost the same, but I had the opportunity to test on a completely different computer. Still a karmic koala, but a desktop one installed on a desktop computer with, of course, the same php, imagick and imagemagick versions and the bug occurs.
It makes sense, but I think it's better to be sure.
 [2009-12-22 11:09 UTC] loranger at free dot fr
Is there a way I can get logs or backtrace in order to help you more ?
 [2010-01-07 04:44 UTC] sualk at lednew dot de
I had a very similar problem rendering EPS and PS-files in CMYK-colorspace. However I solved this problem for me by changing the -sDEVIVE from pam to pnmraw in /usr/lib/ImageMagick-6.4.5/config/delegates.xml

original:

<delegate decode="ps:cmyk" stealth="True" command="&quot;gs&quot; -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=0 &quot;-sDEVICE=pam&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;"/>

changed to:

<delegate decode="ps:cmyk" stealth="True" command="&quot;gs&quot; -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=0 &quot;-sDEVICE=pnmraw&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;"/>

However it is not obvious for me which or if some JPEG-encoding is delegated to an external tool.
 [2010-01-07 04:48 UTC] sualk at lednew dot de
I have forgotten:

The rendering problem with CMYK eps- and ps-files corrected in delegates.xml also occurred with
ImageMagick-6.5.1 and ImageMagick-6.5.8 and could be solved the same way.
 [2010-05-05 08:59 UTC] loranger at free dot fr
No more bug using Lucid Lynx.

(Official lucid lynx versions : Imagick 2.1.1-rc1 - ImageMagick 6.5.7-8 2009-11-26 Q16)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 18:01:32 2024 UTC