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!

Advanced GD Usage: Obtaining fixed ratio area from image to resize

Status
Not open for further replies.

MSRez

Programmer
Dec 22, 2004
57
EU
I've recently got into doing a lot more with GD. What I am now trying to do is to resize images to thumbnails, retain their original aspect ratios but ensure they fit within the same area each time. To do this, it doesn't matter if some clipping occurs on the edges of the original images to create the thumbs so effectively the whole image is sampled using an area of a standard 4:3 aspect ration and then it is scaled down to a smaller size without distortion.

It sounds like it could work, but I have no idea how to sample an area of a larger image.

Any ideas?

Thank you in advance.
 
you can specify a max width and height, and then make sure the resized thumbnail doesnt go over those values.

Or do you want an image that doesnt have an aspect ratio of 4:3 to be clipped horizontally or vertically to make it fit the required aspect ratio?

 
I want images that don't have an aspect ratio of 4:3 to be clipped, yeah.

Also, if the image is considerably taller than it is wide, I would like for it to be resized to fit 4:3 but have a black or white background behind the image.

Thanks for your help so far.
 
Can anyone offer any help with this?

Thanks
 
Well, it's on the right lines but I couldn't get it to do what I want it to do exactly.

Thanks for the suggestion, though.
 
I dont have time right now, I'll put up a sample some time later this week
 
Okay, that would be great.

Thanks :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top