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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image width retrieval 1

Status
Not open for further replies.

Dweezel

Technical User
Feb 12, 2004
428
GB
I'm loading images into a gallery and I need to get their width and height. The image names are stored in a mysql database, and the images themselves in a directory in my public_html.

I'm retrieving the image names and giving them the variable $image.
I'm trying to use:

imagesx('pics/main'.$image);

It's not working, presumably because of the concatenated variable that I've added to the end of the string. I'm sure there's a fairly simple way to convert what's between the brackets above into a string that imagesx can use. Can anyone help me out?
 
imagesx() and imagesy() require an image resource, not the image's filename, as their input. This will require opening the file using imagecreatefrom*() functions.

I recommend that you take a look at getimagesize(), which will take a filename and return the information you need.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
It's not working" is pretty broad. What's not working? Do you get any error messages?

Put an echo statement before your function call to make sure you are looking for the file at the right place.

Ken
 
Thanks guys. That's just what I needed Sleipnir, I don't even have to process the output as the 3rd index of the resource it returns is in the html format: width='xx' height='xx'.

Thanks a lot for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top