how to find a GD image resource "real" filesize.

GD and GD2 are useful libraries for creating graphics on-the-fly. Discuss your PHP GD and GD2 scripts here.

Moderators: onion2k, General Moderators

Post Reply
Salva
Forum Newbie
Posts: 1
Joined: Sun May 17, 2009 10:24 am

how to find a GD image resource "real" filesize.

Post by Salva »

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):

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);
}
?>
 
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
Last edited by Benjamin on Sun May 17, 2009 11:02 am, edited 1 time in total.
Reason: Added [code=php] tags.
Post Reply