how to find a GD image resource "real" filesize.
Posted: Sun May 17, 2009 10:43 am
Hello, I am new to php and strugling with a minor annoyance.
I have a scrip that grabs a image from a remote server (webcam) and feeds it to the visitor browser, with DHTML the script is called every 5 seconds and the image is being updated. The image on the remote server itself is being updated every 6 seconds or so.
Everything works fine, but:
I dont have control over when the image on the remote server is being updated so, every once in a while I grab the image on the remote server while the image on the remote server is being updated, so just a partial image is created.
This is the php code that does it (crude, but it works):
So, I want to check the size (actual filesize, not HxW), I know that if the filesize is less that 10K the imagecreate has failed to get the whole image, but I have no way to check what real filesize the resource $original has.
- Does anyone knows a way to check the memory usage or the size (in file or memory terms) of a GD resource ?
Any other pointer to do correctly what I intend to do will be appreciated.
Thanks for your help.
Salva
I have a scrip that grabs a image from a remote server (webcam) and feeds it to the visitor browser, with DHTML the script is called every 5 seconds and the image is being updated. The image on the remote server itself is being updated every 6 seconds or so.
Everything works fine, but:
I dont have control over when the image on the remote server is being updated so, every once in a while I grab the image on the remote server while the image on the remote server is being updated, so just a partial image is created.
This is the php code that does it (crude, but it works):
Code: Select all
<?
$img_dir = "http://address_of_the_remote_server/";
$original = imagecreatefromjpeg($img_dir."imagename.jpg");
if ($original){
$headers = "Content-type: image/jpeg";
header($headers);
imagejpeg($original);
imagedestroy($original);
}
?>
- Does anyone knows a way to check the memory usage or the size (in file or memory terms) of a GD resource ?
Any other pointer to do correctly what I intend to do will be appreciated.
Thanks for your help.
Salva