From:             [EMAIL PROTECTED]
Operating system: Darwin v6 (Mac Server v10.2)
PHP version:      4.2.3
PHP Bug Type:     GD related
Bug description:  ImageCopy() fails with true color GD2 image

When I am copying a true color image to a regular image using ImageCopy()
PHP dies and nothing is returned.

ie:
(1 sec)
 1482 httpd       27.4%  0:10.96   1     8   164  3.77M- 13.1M+ 6.34M 
38.2M+
(1 sec)
 1514 c++filt3     0.0%  0:00.01   1     9    14    48K   396K   268K 
1.37M 
 1513 crashdump  102.5%  0:01.35   2    15   405  25.2M+ 21.1M+ 33.2M+
59.7M+
 1482 httpd        0.0%  0:10.96   1     8   164  3.77M  13.1M+ 6.34M 
38.2M 
(1 sec)
 1514 c++filt3     0.0%  0:00.01   1     9    14    48K   396K   268K 
1.37M 
 1513 crashdump   99.8%  0:02.40   2    15   405  25.2M  21.1M  33.2M 
59.7M 
 1512 top          4.7%  0:00.42   1    15    18   208K   376K   488K 
13.8M 
 1482 httpd        0.0%  0:10.96   1     8   164  3.77M  13.1M  6.34M 
38.2M 

Here are some example scripts. Notice that ImageCopyResized() works, but
ImageCopy() doesn't in the last script.

This code works:
<?php
header( "Content-type: image/png" );

$medimg = $_SERVER['DOCUMENT_ROOT'] .
"/riverdata/images/world_map_med.gd2";

//Work-around for another bug.
$x = (int) '1053';
$y = (int) '626';

$img = ImageCreateFromGD2Part( $medimg, $x, $y, 800, 600 );

$medimg = ImageCreateTrueColor( 800, 600 );
ImageCopy( $medimg, $img, 0, 0, 0, 0, 800, 600 );
ImageDestroy( $img );
$img = $medimg;

$final_img = ImageCreate( 800, 600 );
imagecopyresized ( $final_img, $img, 0, 0, 0, 0, 800, 600, 800, 600);
ImageDestroy( $img );
$img = $final_img;

ImagePNG( $img );
ImageDestroy( $img );
?>

This code works:
<?php
header( "Content-type: image/png" );

$medimg = $_SERVER['DOCUMENT_ROOT'] .
"/riverdata/images/world_map_med.gd2";

//Work-around for another bug.
$x = (int) '1053';
$y = (int) '626';

$img = ImageCreate( 800, 600 );

$medimg = ImageCreateTrueColor( 800, 600 );
ImageCopy( $medimg, $img, 0, 0, 0, 0, 800, 600 );
ImageDestroy( $img );
$img = $medimg;

$final_img = ImageCreate( 800, 600 );
imagecopy ( $final_img, $img, 0, 0, 0, 0, 800, 600);
ImageDestroy( $img );
$img = $final_img;

ImagePNG( $img );
ImageDestroy( $img );
?>

This code works:
<?php
header( "Content-type: image/png" );

$medimg = $_SERVER['DOCUMENT_ROOT'] .
"/riverdata/images/world_map_med.gd2";

//Work-around for another bug.
$x = (int) '1053';
$y = (int) '626';

$img = ImageCreateFromGD2Part( $medimg, $x, $y, 800, 600 );

$medimg = ImageCreateTrueColor( 800, 600 );
ImageCopy( $medimg, $img, 0, 0, 0, 0, 800, 600 );
ImageDestroy( $img );
$img = $medimg;

ImagePNG( $img );
ImageDestroy( $img );
?>

This code works:
<?php
header( "Content-type: image/png" );

$medimg = $_SERVER['DOCUMENT_ROOT'] .
"/riverdata/images/world_map_med.gd2";

//Work-around for another bug.
$x = (int) '1053';
$y = (int) '626';

$img = ImageCreateFromGD2Part( $medimg, $x, $y, 800, 600 );

$final_img = ImageCreate( 800, 600 );
imagecopy ( $final_img, $img, 0, 0, 0, 0, 800, 600);
ImageDestroy( $img );
$img = $final_img;

ImagePNG( $img );
ImageDestroy( $img );
?>

This code doesn't:
<?php
header( "Content-type: image/png" );

$medimg = $_SERVER['DOCUMENT_ROOT'] .
"/riverdata/images/world_map_med.gd2";

//Work-around for another bug.
$x = (int) '1053';
$y = (int) '626';

$img = ImageCreateFromGD2Part( $medimg, $x, $y, 800, 600 );

$medimg = ImageCreateTrueColor( 800, 600 );
ImageCopy( $medimg, $img, 0, 0, 0, 0, 800, 600 );
ImageDestroy( $img );
$img = $medimg;

$final_img = ImageCreate( 800, 600 );
imagecopy ( $final_img, $img, 0, 0, 0, 0, 800, 600);
ImageDestroy( $img );
$img = $final_img;

ImagePNG( $img );
ImageDestroy( $img );
?>

Sorry if this is a dupe. I some other bugs that may have something to do
with this, but then again, maybe not. If you want a GD2 image for testing,
you can use this one:
http://144.92.10.251/riverdata/images/world_map_med.gd2
-- 
Edit bug report at http://bugs.php.net/?id=19700&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=19700&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=19700&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=19700&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=19700&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=19700&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=19700&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=19700&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=19700&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=19700&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=19700&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=19700&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=19700&r=dst

Reply via email to