Hi,
GD lib is seems to work just fine for JPEG images, but not for PNG. When I try to load an PNG image, I always get the CGI program Error message that is error in phpts.exe.
Here is the demo code:
<?php
LoadJpeg( "sample.jpg" );
//LoadJpeg( "sample.png" );
function LoadPNG ( $imgname ) {
$im = @ImageCreateFromPNG ($imgname); // Attempt to open
if (!$im) { // See if it failed
$im = ImageCreate (150, 30); // Create a blank image
$bgc = ImageColorAllocate ($im, 255, 255, 255);
$tc = ImageColorAllocate ($im, 0, 0, 0);
ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc);
// Output an errmsg
ImageString ($im, 1, 5, 5, "Error loading $imgname", $tc);
}
ImagePNG( $im );
}
function LoadJpeg ( $imgname ) {
$im = @ImageCreateFromJpeg ($imgname); // Attempt to open
if (!$im) { // See if it failed
$im = ImageCreate (150, 30); // Create a blank image
$bgc = ImageColorAllocate ($im, 255, 255, 255);
$tc = ImageColorAllocate ($im, 0, 0, 0);
ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc);
// Output an errmsg
ImageString ($im, 1, 5, 5, "Error loading $imgname", $tc);
}
ImageJpeg( $im );
}
?>