filename.php as an image?
Posted: Wed Oct 31, 2007 2:11 am
Hello all,
I have a php script called getimage.php. The contents is:
The $client, $serverlist, and $bandwith variables connect to a backend API and these are working. The $data variable gets info from the API, and the info that this variable gets is a base64 string for an image that is generated by an API for rrdtool. then I change the header to another API result .. which is actually image/png in this case. Then $image decodes the base64 string and I echo the $image, which displays the PNG image.
I want to resize the PNG image. I've looked into GD, however, I keep getting errors:
The above output is from another file that I have not listed, but that isn't the point.
My point is, and my question is, how do I go about getting the dimesions of this PNG file (filename.php)? It appears that GD sees the .php extension and doesn't think its a PNG file, however, the header is PNG file. So, I'm lost.
Any help is appriciated.
Thanks,
Drew
I have a php script called getimage.php. The contents is:
Code: Select all
<?
require ('./api.class.php');
function imageFile() {
$client = new Client; // pay no attention to this. This is a connection string that I took out.
$serverList = $client->getServerList(); // same for this
$bandwith = $client->getBandwidthimage(10702); // and this .. these are all api related things that work
$data = $bandwith['file'];
header("Content-type: ".$bandwith['file_type']);
$image = base64_decode($data);
echo $image;
}
imageFile();
}
?>I want to resize the PNG image. I've looked into GD, however, I keep getting errors:
Code: Select all
imagecreatefrompng() [<a href='function.imagecreatefrompng'>function.imagecreatefrompng</a>]: 'getimage.php' is not a valid PNG file
imagecopyresized(): supplied argument is not a valid Image resource
PHP Warning: imagepng(): supplied argument is not a valid Image resource inMy point is, and my question is, how do I go about getting the dimesions of this PNG file (filename.php)? It appears that GD sees the .php extension and doesn't think its a PNG file, however, the header is PNG file. So, I'm lost.
Any help is appriciated.
Thanks,
Drew