php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23808 Different behaviour of gd in blend images with 4.3.2rc4 than 4.3.1
Submitted: 2003-05-26 04:24 UTC Modified: 2003-07-02 06:26 UTC
Votes:7
Avg. Score:5.0 ± 0.0
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:2 (33.3%)
From: i dot a at signalsystem-bz dot it Assigned:
Status: Closed Package: GD related
PHP Version: 4.3.2RC4 OS: Win2k server
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
41 + 25 = ?
Subscribe to this entry?

 
 [2003-05-26 04:24 UTC] i dot a at signalsystem-bz dot it
I had under php 4.3.1 some code to blend in transparency a logo over some pictures before displaying them - all was working perfectly.
When i installed php 4.3.2rc4, i noticed that the same code stopped working - where first was blending 2 images, now is acting this way:
- with high transparency value in imagecopymerge, the 2nd image covers totally the destination one and the transparent color is drawed all grey
- with low transparency value in imagecopymerge, the 2nd image transparent color becomes very dark-black and covers the destination image

the code i'm using is below:

if (isset($_REQUEST['img'])) $img=$_REQUEST['img']; else $img='';
	
$b = imagecreatefromjpeg($img);
$bx = imagesx($b);
$by = imagesy($b);
ImageAlphaBlending($b, true);
$logoImage = ImageCreateFromPNG('logo.png');
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);
if ($logoW > $bx or $logoH > $by) 
{
	$x1 = $bx;
	$y1 = $bx*$logoH/$logoW;
	if ($x1 > $bx or $y1 > $by)
	{
		$y1 = $by;
		$x1 = $by*$logoW/$logoH;
	}
	$b1 = imagecreatetruecolor($x1,$y1);
	imagecopyresampled($b1,$logoImage,0,0,0,0,$x1,$y1,$logoW,$logoH);
	imageDestroy($logoImage);
	$logoImage = $b1;
	$logoW = $x1;
	$logoH = $y1;
}
ImageCopyMerge($b,$logoImage,($bx - $logoW)/2,($by - $logoH)/2,0,0,$logoW,$logoH,14); 
	
imagejpeg($b,"blend.jpg",90); 
imageDestroy($b);

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-01 04:28 UTC] phpuser at panoramas dot de
I was going to file this as a new bug, but thought i'd rather add it here, since it's the same basic problem:

After upgrading to 4.3.2, the imagecopymerge function is broken. Reverting to 4.3.1 removes the error.

My configure line: (unchanged since 4.3.1)
'./configure' '--with-mysql' '--prefix=/mysrv/php' '--enable-ftp' '--with-apxs=/mysrv/apache/sbin/apxs' '--with-config-file-path=/mysrv/php-conf' '--disable-pear' '--enable-track-vars' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-zlib-dir=/usr/local' '--disable-cli' '--with-t1lib=/usr/local'

Summary of script function:
- Takes one image A from file (JPEG 24bit).
- generates another image B with same dimensions, 24 bit, and fills it with 50 percent gray
- (left out: gets a set of imagemap coordinates from a database and draws them as black outline, white area inside the image B)
- merges image B on top of image A with 40 percent transparency
- returns the result.

Effect of error:
No blending occurs with 4.3.2. Only image B is returned, albeit "weaker" or "stronger" depending on the transparency setting in imagecopymerge().
Leaving out the imagecopymerge() command returns the original image A, as expected.
Moving the coordinates results in a black background being visible (should be image A). 

My unqualified guess:
Looks as if imagecopymerge() takes a black image instead of image A.

Side notes:
replacing imagecopymerge with imagecopymergegray actually returns the both images overlaid, but with palette image color mixup effects.

Example source code
(requires a jpeg image "test.jpg" of arbitrary size to test)

-- begin code --

$uim = imagecreatefromjpeg("test.jpg")
    or die ("Cannot Initialize new GD image stream");

imagealphablending ($uim, TRUE ); # leaving this out changes nothing

#### fill overlay with gray

$im = imagecreatetruecolor( imagesx($uim) , imagesy($uim) ); # Overlay-Bild

$migra=imagecolorallocate ($im, 128,128,128);

imagefilledrectangle ( $im , 0,0 , imagesx($im)-1 , imagesy($im)-1 , $migra );

# database drawin left out here

imagecopymerge ( $uim, $im, 0, 0, 0, 0, imagesx($uim), imagesy($uim), 40);

header ("Content-type: image/jpeg");
imagejpeg ($uim ,'', 75);

imagedestroy($uim);
imagedestroy($im);

-- end code --
 [2003-06-03 02:01 UTC] i dot a at signalsystem-bz dot it
I putted the images as you requested ..
http://signalsystem.merseine.nu/test/

image1.jpg is the main image;
image2.png is the image that's "slitted" in trasnparency over the first

image_431.jpg is the result of it in 4.3.1 (nice and good)
image_432.jpg is the result of it in 4.3.2 (wrong and ugly)
 [2003-07-01 16:34 UTC] christophe dot bidaux at netcourrier dot com
i made new tests with several php versions and i've putted the results on this page : http://christophe.bidaux.free.fr/imagecopymerge/imagecopymerge.html

the first image is the original image and the others are made with the same php program shown at the bottom.

the php version is written in the top-left corner of the images.

only the 4.3.1 version gives me a good result.

i use the binaries as they are and i use the same php.ini for all my tests.

i run php on an Apache/1.3.20 Server on Windows 98.
 [2003-07-02 06:26 UTC] pajoye@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

Hello,

Fixed in both php5 and php 4.3 branches.

Merci Christophe :)

pierre
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 04:01:27 2024 UTC