php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34131 Artifact left on transparent gifs using image filters
Submitted: 2005-08-15 04:29 UTC Modified: 2005-12-07 01:00 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: mtjo at conninc dot com Assigned: pajoye (profile)
Status: No Feedback Package: GD related
PHP Version: 5CVS-2005-08-15 OS: *
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mtjo at conninc dot com
New email:
PHP Version: OS:

 

 [2005-08-15 04:29 UTC] mtjo at conninc dot com
Description:
------------
When using the image filters on transparent gif images, it leaves an artifact at x,y:1,1 that is approx 170px long. It appears to be the background color used when the gif is created in a desktop app. This does not affect transparent pngs. This was tested on PHP5.02 and 5.04 with the bundled gd 2.0.28. See http://mike.aplosmedia.com/dev/brightness/test_brightness.php for an example using the brightness filter.

Loaded modules:
core mod_win32 mpm_winnt http_core mod_so mod_access mod_actions mod_alias mod_asis mod_auth mod_autoindex mod_cgi mod_dir mod_env mod_imap mod_include mod_isapi mod_log_config mod_mime mod_negotiation mod_rewrite mod_setenvif mod_userdir mod_php5

Reproduce code:
---------------
<?php

header( 'Content-type: image/gif' );

$filename = 'sample.gif'; // any transparent gif
$source   = imagecreatefromgif( $filename );

imagefilter( $source, IMG_FILTER_GAUSSIAN_BLUR );

// Set background transparent
imagecolortransparent( $source, imagecolorat( $source, 1, 1 ) );

imagegif( $source );
imagedestroy( $source );

?>

Expected result:
----------------
The gif image with filtering and a transparent background.

Actual result:
--------------
The gif image with filtering and a transparent background with the artifact.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-15 06:36 UTC] mtjo at conninc dot com
Should say artifact at x,y:2,1 or x,y:2,2 and width varies.
 [2005-08-15 07:35 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-08-16 02:09 UTC] mtjo at conninc dot com
I tried the script with the same results using the following builds.

PHP 5.1 Fri, 12 Aug 2005 23:13:30 +0000
PHP 5.04 Mon, 08 Aug 2005 23:22:28 +0000

I noticed that both of those still use the gd 2.0.28 build. I can't find a complied dll for win32 for the latest 2.0.33 build. Since full gif support was again added at 2.0.28, perhaps it is related to this. Is there a php_gd2.dll for the 2.0.33 lib available?
 [2005-08-16 02:20 UTC] pajoye@php.net
Please provide the sources images, the result images (what you get) and the result you may expect (approximativally).

Please use the bundled GD only, your php must be compiled using "--with-gd" not --with-gd=/...

Using Gif as output of a filtered image will reduce the quality of any filter...
 [2005-08-16 02:32 UTC] mtjo at conninc dot com
The following link demonstrates the problem. This is on a RH server running PHP5.04.

http://mike.aplosmedia.com/dev/brightness/test_brightness.php
 [2005-08-16 06:54 UTC] mtjo at conninc dot com
After further testing, I found that pngs will also produce the artifact. After playing around with the code, I came up with two methods to correctly reproduce the transparency in both png and gif images. For the gifs, I do the filtering, save as a temp png file, create a new png file, set transparent then save as gif. The png required that I determine a color not in the source images palette and set that as the background to be set as transparent. If you can point me to a more efficient method for these, I'm all ears. IMO, the prob is with the limitation and inferiority of the gif format and probably there is something in the gd lib affecting this too. I hope this helps in some way.
 [2005-08-16 06:56 UTC] mtjo at conninc dot com
Forgot to add, here are the examples to reproduce the correct image outputs.

http://mike.aplosmedia.com/dev/test_gif/test_gif.php
 [2005-08-16 14:56 UTC] mtjo at conninc dot com
Actually, it is becoming apparent that it is hit or miss depending on the actual image whether you can accurately set the transparent index on an image using the image filters. They obviously do not handle transparency natively.
 [2005-11-29 14:42 UTC] pajoye@php.net
They do not, as in many cases the destination pixels are computed using many source pixels. Filters are used to process photographies, graphs or scans, or for some artistic effects.

I'm not sure of the right solution to this problem, but the transparent color has nothing to do with colors with a transparency channel.

Third problem, the php_gd has more bugs fixed than the official GD 2.0.33. From a features point of view only the animated are missing. The filters do not exist in the official GD.

What's your solution to solve the transparency problems?

Background color can be easily fixed, as we do in imagerotate.
 [2005-12-07 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".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 05:01:27 2024 UTC