I have a problem with image manipulation in php. As they say, a picture paints a thousand words so below is an image to assist me in explaining my situation.
I have a canvas (the picture of a car) and a container (the red rectangle) and the image above is my initial setup. Here are the details that I know about my initial setup:
- Dimension of the canvas (width & height)
- Dimension of the container (width & height)
- Position of the container relative to the top left of the canvas (x, y)
Next I apply a rotation on the canvas at a certain angle counter-clockwise. Assuming the centre of the rotation is the centre of the canvas itself.
As of this step, I know 2 additional details:
- The angle of the rotation
- The direction of the rotation (counter-clockwise)
Things to take note of:
- The container itself didn't rotate, just the canvas.
- The dimension of the canvas may have changed. In this case, both the width and height of the canvas have increased.
Details that I DO NOT know anymore AFTER the rotation:
- Dimension of the canvas
- Position of the container relative to the top left of the canvas
Then, the container is used to crop the canvas at its current position. The image below is the result I'm trying to achieve using php.
I have never done any image manipulation in php before. Code examples are greatly appreciated.