PHP cut section out of image, possible?

Soldato
Joined
26 Aug 2006
Posts
9,726
Location
62.156684,-49.781113
Thought this deserved a separate thread to my other, even though it relates to my same page, it's something I could need to know in general.

I'm creating an image gallery: http://gumbald.co.uk/photos/, but after putting some portrait ones in there, I think they look silly. So I want all my thumbnails to be landscape.

For the portrait photos, I envisaged this would be a section cut from the middle of them. However, I can't find a way to do this automatically. I don't want to have to make the thumbnails myself, I've got a perfectly good upload page which puts entries into mysql also.

Can it be done? Something similar to "imagecopyresize"?
 
you don't need imagecopy to do this; in imagecopyresampled, you have int_src_x and int_src_y, which will allow you to take the original image from different co-ordinates - then just use imagejpeg/imagepng or some similar to output the image to file/screen
 
That didn't seem to work, I was getting black bars down the sides of the images. I do an imagecopyresampled to take the image to the correct width, then cut the section out of the middle of it...
 
That didn't seem to work, I was getting black bars down the sides of the images.

sounds like you weren't doing the calculations to keep the aspect ratio for non-square images? i assume you were just using a fixed size for your new image?

but not that it matters now anyway.... :p
 
Back
Top Bottom