Howzit guys,
Any one know of a way to crop an image from the center of the image in php? What I want to achieve is to take an uploaded photo and create a thumbnail of a certain size from this. The problem is that a use can upload a image of any dimension.
I know it is possible to crop an image, but would like to get some comments on the approach.
Here is my idea.
- Determine the width and height
- From the width, determine the middle
- From the middle, subtract half the desired width. This will give me my x coordinate
- do the same for my height to get my y coordinate
- Crop from these coordinates.
Any body know of a better idea, as this seems a bit messy.