php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19418 ImageCreateFromGD2Part() creates invalid img resource
Submitted: 2002-09-15 12:58 UTC Modified: 2002-09-20 19:49 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: sprice at wisc dot edu Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.2.3 OS: Darwin (Mac OS X)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sprice at wisc dot edu
New email:
PHP Version: OS:

 

 [2002-09-15 12:58 UTC] sprice at wisc dot edu
Here is the script that I am trying to run:
<?php
header( "Content-type: image/png" );
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header( "Cache-Control: no-store, no-cache, must-revalidate" );
header( "Pragma: no-cache" );


$medimg = $_SERVER['DOCUMENT_ROOT'] . "/riverdata/images/world_map_med.gd2";
$img = ImageCreateFromGD2Part( $medimg, 1, 1, 800, 600 );

//Send it out.
ImagePNG( $img );
ImageDestroy( $img );

?>

When I load this script from the browser Chimera, it fails with the error "The image ?http://144.92.10.251/riverdata/test.php? cannot be displayed, because it contains errors."

When I load this script from the browser OmniWeb, it fails with this error "Cannot Load Address; Attempted read off end of buffer"

I tried changing "ImagePNG( $img );" to "ImageJPEG( $img );" and the content-type header to jpeg, and then it works.

ImagePNG() works in the rest of my scripts, which leads me to believe that it may be a problem with the data recieved from ImageCreateFromGD2Part().

If you want a .gd2 image for testing, you can use "http://144.92.10.251/riverdata/images/world_map_med.gd2". It is a 20 meg file of the earth.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-18 20:25 UTC] sprice at wisc dot edu
If I copy the image to a new image resource, I can use ImagePNG() just fine. I am changing the summerey to reflect that this is a ImageCreateFromGD2Part() error and not a ImagePNG() error.

This is the changed script that works just fine:

<?php
header( "Content-type: image/png" );
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header( "Cache-Control: no-store, no-cache, must-revalidate" );
header( "Pragma: no-cache" );

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

$medimg = ImageCreateFromGD2Part( $medimg, 1, 1, 800, 600 );

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

//Send it out.
ImagePNG( $img );
ImageDestroy( $img );

?>
 [2002-09-20 19:49 UTC] iliaa@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.

This problem is not the fault of PHP. After trying your script I found that gd sends the following errors to stderr (you can most likely find them in Apache's error_log).
gd-png: fatal libpng error: Invalid number of colors in palette 
gd-png error: setjmp returns error condition void

Which is why a corrupt image you are seeing gets created.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 15:01:31 2024 UTC