I am trying to set up a photo gallery. But with the thumbnails I'm using, rather than reducing the size of the image, I just want to crop part of the picture from a certain size.
Like say I have a 400 x 400 px picture. Rather than reducing that picture to 100 x 100 px, I want to take part of that picture (any random part of the picture) and use that for my thumbnail.
So I think the way to accomplish this is to find a random coordinate on a picture and make the other 3 sets of coordinates from there. Except I have no idea where to start. Any help is appreciated. Thanks.I am sure there is... but if you are displaying a lot of images as thumbs then this is going to put an awful amount of pressure on your server.
I reckon you'll need a php programmer of some knowledge to write an individual script for that. No mean task.Hey uh the function your looking for is found here: <!-- m --><a class="postlink" href="http://us2.php.net/manual/en/function.imagecopy.php">http://us2.php.net/manual/en/function.imagecopy.php</a><!-- m -->. The imagecopy function allows you to copy one section of an image to another, so all you have to do is create a secondary image whose dimensions are the same as the thumbnail.
As for the geometry question, find out the other three coordinates only takes a bit of thinking. Now think about it this way, basicly you describing a vector from the top left hand corner to the bottom left hand corner, and this is discribed byx+a,y+b)
The top right hand corner is found by: (x+a, y)
The bottom left hand corner is found by: (x, y+b)
The bottom right hand corner is found by (x+a, y+b)
And a,b are the dimensions of the cropped image.
Ex:
The cropped image size is: (100,100) and you begin cropping at: (32,36)
top-right : ( 32 + 100, 36) = (132, 36)
bottom-left : ( 32, 36 + 100) = (32, 136)
bottom-rigth: ( 32 + 100, 36 + 100) = (132, 136)
I hope this helps
Like say I have a 400 x 400 px picture. Rather than reducing that picture to 100 x 100 px, I want to take part of that picture (any random part of the picture) and use that for my thumbnail.
So I think the way to accomplish this is to find a random coordinate on a picture and make the other 3 sets of coordinates from there. Except I have no idea where to start. Any help is appreciated. Thanks.I am sure there is... but if you are displaying a lot of images as thumbs then this is going to put an awful amount of pressure on your server.
I reckon you'll need a php programmer of some knowledge to write an individual script for that. No mean task.Hey uh the function your looking for is found here: <!-- m --><a class="postlink" href="http://us2.php.net/manual/en/function.imagecopy.php">http://us2.php.net/manual/en/function.imagecopy.php</a><!-- m -->. The imagecopy function allows you to copy one section of an image to another, so all you have to do is create a secondary image whose dimensions are the same as the thumbnail.
As for the geometry question, find out the other three coordinates only takes a bit of thinking. Now think about it this way, basicly you describing a vector from the top left hand corner to the bottom left hand corner, and this is discribed byx+a,y+b)
The top right hand corner is found by: (x+a, y)
The bottom left hand corner is found by: (x, y+b)
The bottom right hand corner is found by (x+a, y+b)
And a,b are the dimensions of the cropped image.
Ex:
The cropped image size is: (100,100) and you begin cropping at: (32,36)
top-right : ( 32 + 100, 36) = (132, 36)
bottom-left : ( 32, 36 + 100) = (32, 136)
bottom-rigth: ( 32 + 100, 36 + 100) = (132, 136)
I hope this helps