php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30863 imagecolortransparent and imagetruecolortopalette don't mix
Submitted: 2004-11-22 16:53 UTC Modified: 2004-11-23 15:30 UTC
From: hp at oeri dot ch Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: 5.0.2 OS: Windows XP
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: hp at oeri dot ch
New email:
PHP Version: OS:

 

 [2004-11-22 16:53 UTC] hp at oeri dot ch
Description:
------------
If I create a truecolor image and
a) set a color as transparent
b) use imagetruecolortopalette
the result is offset by one in "x" direction and a black vertical line at x=0.

Leaving out either a or b gives the correct result (no offset).

Didn't find this bug anywhere, am however unable to compile on Windows.

Reproduce code:
---------------
<?php
		header( "Content-Type: image/png" );

		$im = imagecreatetruecolor( 750, 400 );

		$bg = imagecolorallocate( $im, 0xFF, 0xAA, 0xAA );
		imagecolortransparent( $im, $bg );											// EITHER THIS
		imagefilledrectangle( $im, 0, 0, 749, 399, $bg );

		$c2 = imagecolorallocate( $im, 0x01, 0x23, 0x45 );
		imagerectangle( $im, 0, 0, 749, 399, $c2 );

		imagetruecolortopalette( $im, false, 256 );							// OR THAT
		imagepng( $im );
?>

Expected result:
----------------
palette image, 750x400 with a rectangle along the borders

Actual result:
--------------
palette image, 750x400, with a rectangle open to the right (offset 1)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-23 15:30 UTC] pajoye@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Use dithering to get out of that. The color approximation (even with 2colors..) is "better".

--Pierre
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 13:01:33 2025 UTC