php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34992 imageconvolution does not respect alpha
Submitted: 2005-10-26 11:15 UTC Modified: 2015-05-17 04:22 UTC
Votes:8
Avg. Score:4.6 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:1 (16.7%)
Same OS:2 (33.3%)
From: jaanus at underwerks dot com Assigned: pajoye (profile)
Status: No Feedback Package: GD related
PHP Version: 6CVS-2005-10-26 (snap) OS: Linux 2.6.13
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jaanus at underwerks dot com
New email:
PHP Version: OS:

 

 [2005-10-26 11:15 UTC] jaanus at underwerks dot com
Description:
------------
imageconvolution destroys 8bit alpha channel in subject image

Reproduce code:
---------------
<?PHP
$img=imagecreatefromjpeg("image.png");
imageconvolution($img,array(array(-1,-1,-1),array(-1,16,-1),array(-1,-1,
-1)), 8,0);
imagejpeg($img,"test.png");
?>

Expected result:
----------------
A sharpened image with intact alpha channel, alternavly sharpened alpha channel

Actual result:
--------------
Image is flattened against black background even if the color data of the background indicates it should be white.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-26 12:42 UTC] tony2001@php.net
Assigned to the maintainer.
 [2005-10-26 14:52 UTC] pajoye@php.net
Please provide the images you use for this test and images you like to have as result (specifying which software you use).

I'm not sure about the use of alpha with convolution filter but aesthetic toys. Interpolate the alpha using the convolutions make little sense, what it does now is to get the src alpha value for a given result pixel (x,y).

As a second point, you talk about background color, this is something different as the alpha  channel for a given pixel.
 [2005-11-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-08-06 09:32 UTC] ghosh at q-one dot com
This bug still occurs with 5.2.2 which is fairly new. Can't test 5.2.3 right now but it doesnt mention anything about imageconvolution in the changelog so I believe this is still unfixed.

The original post about "background color" is a little bit misleading.
To put it more simply: Any alpha channel information simply gets destroyed when using imageconvolution. An example image isnt really necessary because it happens with ANY png with alpha channel. I can provide one on request if absolutely necessary though.

Use cases? For instance I have a dynamically generated price tag here as alpha png. I rotate it with imagerotate. Rotation makes it somewhat blurry. So afterwards I try sharpening it with imageconvolution. There you go: Alpha channel info goes down the drain...
 [2007-08-06 10:01 UTC] pajoye@php.net
By the way, I suppose it is a typo but you are using the jpeg functions to load and save PNG. It is not going to work (and jpeg has no alpha support).

"This bug still occurs with 5.2.2 which is fairly new."

What make you think that anything has changed regarding this behavior?

In the meantime, I figured out the source of the problem. Feedback > open.


 [2007-10-30 07:50 UTC] michael dot buckley at ozemail dot coml dot au
I am trying to make slightly blurred drop shadows for some text, but since I then need to layer it over the top of another image it needs to keep the alpha layer.

Right now I am using a color to alpha function to undo this effect, but it is slow.

Any one working on this?
 [2009-03-26 17:52 UTC] jcolby at remove dot this dot acsol dot net
The fix to this:

In reference functions I manged to pinpoint a duplicate problem and solution, the destination resource image internal to the imageconvolution function needs to have the imagesavealpha flag set to true or equivalent after creation. Thats all this needs to be resolved.

imagesavealpha($resource, true);
 [2015-05-06 22:57 UTC] cmb@php.net
-Status: Assigned +Status: Feedback
 [2015-05-06 22:57 UTC] cmb@php.net
Just as jcolby said: using imagesavealpha() to save the alpha
channel should be sufficient.
 [2015-05-17 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 09:01:26 2024 UTC