Bruce Gust
asked on
Using getimagesize
I want to create a script that looks to see if the image that's getting ready to be displayed in my loop exceeds a 3:4 ratio.
Right now, I've got the width of my photos being displayed as 100. If they're close to 75 px high, the page looks great. But when I get into those dynamics where a picture is resized to 100 px wide and the hieght is 125, things start to look goofy.
I found getimagesize, but I've yet to be able to get my arms around how I grab the width, so I can compare it to the height and determine if it matches that ratio that looks the best with my page.
How do you grab the width and height using getimagesize?
Right now, I've got the width of my photos being displayed as 100. If they're close to 75 px high, the page looks great. But when I get into those dynamics where a picture is resized to 100 px wide and the hieght is 125, things start to look goofy.
I found getimagesize, but I've yet to be able to get my arms around how I grab the width, so I can compare it to the height and determine if it matches that ratio that looks the best with my page.
How do you grab the width and height using getimagesize?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Guys, question...
The solutions look great, but while I can trace the logic of the code to an extent, I'm thinking a question is in order as well as a look at what I'm trying to do so you can tell me if your solutions are what it is that I need.
Head out to http://www.countryshowdown.com/Texaco You'll notice that the photos in the photo gallery change everytime you refresh the screeen. I've hardwired the size of the picture to be 100 X 75. While the symetery is OK, you'll see that some of the images which don't have a 3:4 ration are being obviously stretched and that's what I'm trying to avoid.
Initially I thought I would just skip any image that was outside the dimensions that would look good, but now I'm seeing that I don't have a lot of images that match those measurements.
So I want to resize the images without them looking distorted. Do your suggestions accomplish that?
The solutions look great, but while I can trace the logic of the code to an extent, I'm thinking a question is in order as well as a look at what I'm trying to do so you can tell me if your solutions are what it is that I need.
Head out to http://www.countryshowdown.com/Texaco You'll notice that the photos in the photo gallery change everytime you refresh the screeen. I've hardwired the size of the picture to be 100 X 75. While the symetery is OK, you'll see that some of the images which don't have a 3:4 ration are being obviously stretched and that's what I'm trying to avoid.
Initially I thought I would just skip any image that was outside the dimensions that would look good, but now I'm seeing that I don't have a lot of images that match those measurements.
So I want to resize the images without them looking distorted. Do your suggestions accomplish that?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your original question didn't mention resizing the images, you just said you wanted to check the aspect ratio of the photos. Resizing and cropping is a whole different kettle of fish. It's important when you ask your original question that you specify exactly what it is you are trying to accomplish.
ASKER
billmercer is right. I was originally looking for a way to weed out the photos that exceeded the dimension I needed in order for the site to look symetrical. I do have to resize the images, though, and I''m not completely understanding the code above. So, I'll close this question and award points based on the original inquiry with a little delegated to those who weighed in, and then I would invite whoever is interested to look at https://www.experts-exchange.com/questions/26862402/How-do-I-get-this-function-to-work.html
Thanks!
Thanks!
Cheers