Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

record image file size of remote file

Status
Not open for further replies.

rmfrance

Programmer
Nov 1, 2001
9
GB
Is there a way to grab the size / width and height of an image (jpeg/gif) from a file stored in a remote location outside the url path on the server.
O/S = Win 2000, Apache, PHP4
 
Take a look at my resize images on the fly thread just a couple before yours, you'll see that just the upper portion of it will suite your need if all you want is the height and width.

Code:
..........
    /* loads image passed thru script
    ie: gd.php?img_name=zoom.jpg */
    $src_img = imagecreatefromjpeg($img_name);
    /* desired width of the thumbnail */
    $picsize = 123; 
    /* grabs the height and width */
    $new_w = imagesx($src_img);
    $new_h = imagesy($src_img);
..........
Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 
it's an hard thing.

One way (not tested) is read the file and saving it in the temp dir. Now you can see the filesize and the size in px of the image.

try $image=implode("",file("
$fp=fopen("/tmp/myimage.gif","wb+");
fwrite($fp,$image,strlen($image));
fclose($fp);

I didn't tested, is only theorical. I hope it can help you out. Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
he was asking for Dimension size, Height/Width, not file size , which is pretty easy to obtain also. Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 
It's actually the file size, the height and the width I want, but all php manuals say you can't get the size of a file from a file outside the url.

ie.
/usr/htdocs/ web pages.html
/secret dir/images/ image.gif
 
And if my code works, he can get them both cause it has the file in his filesystem. Also, you can get this info on files outside your url, if they are in your filesystem.
Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top