Page 1 of 1

get image size from picture off another web server

Posted: Fri Feb 16, 2007 8:28 pm
by psychotomus
how can you get the image size of an external picture located on another server?

Posted: Fri Feb 16, 2007 8:34 pm
by superdezign
file_get_contents() and filesize()?

Posted: Fri Feb 16, 2007 9:11 pm
by psychotomus
how can I get the type of a file?

Posted: Fri Feb 16, 2007 9:27 pm
by superdezign
filetype()

Images start with "image/"
i.e. "image/jpeg," "image/gif," "image/pjpeg"

Posted: Fri Feb 16, 2007 10:49 pm
by Kieran Huggins
if by "image size" you mean the dimensions of the picture, you'll have to load it with imagecreatefromjpeg() (or one of it's brothers) and then use imagesx() and imagesy()

Posted: Sat Feb 17, 2007 2:28 am
by ckh
I was using getimagesize() to check off site banner sizes to make sure they were a max of 480X60. Something like:

Code: Select all

$size = getimagesize($imageURL);

if ($size[0] > 468 || $size[1] > 60) {
  // Reject it
}

Posted: Sat Feb 17, 2007 8:40 am
by feyd
Just a note: getimagesize() returns a lot of information about a file if it reads as an image to PHP. Dimensions and image type are just a piece of the information returned.

Posted: Sat Feb 17, 2007 12:02 pm
by Kieran Huggins
:banghead:
That would be the easier way.. by far!

Nice one feyd :-)