php: get image size

by prettyscripts on 2008-12-04 14:11:21

php

to access basic image information like width and height, call getimagesize(), which returns data in array format as follows

Code:

Array
(
    [0] => 640  // width
    [1] => 426  // height
    [2] => 2    // not sure what this is. anyone?
    [3] => width="640" height="426" // for <img> param
    [bits] => 8
    [channels] => 3
    [mime] => image/jpeg  // mime type
)

note: this function does not require gd library.

Tags: image, php, size

1 comment

Comment by Allan @ 2010-12-29 16:13:07
*****
This was just what I was looking for. Needed a script to get the width and height so that I could dynamically position an image based on the best of it's height or width.

Many thanks

Leave a comment


Your email address will not be revealed on this site.
PoorExcellent
note: all comments are moderated. do not spam and do not advertise. only comments relevant to the post will be published.
(Line breaks become <br />)
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)