bmer Posted September 23, 2013 Share Posted September 23, 2013 Hi, I'm a new to web development I and was hoping someone here can help me. I'm trying to crop the middle part of a tall (or wide) picture in to a square. My picture looks like this: I'd like to crop it's middle in to a square like this: Sadly, my pictures end up looking like this: Here's my PHP code that I am using: if($OriginalHeight > $OriginalWidth){ $StartY = $OriginalHeight / 4; $StartX = 0; $EndY = $StartY * 3; $EndX = $OriginalWidth; } if($OriginalHeight < $OriginalWidth){ $StartY = 0; $StartX = $OriginalWidth / 4; $EndY = $OriginalHeight; $EndX = $StartX * 3; } if($OriginalHeight == $OriginalWidth){ $StartY = 0; $StartX = $OriginalWidth; $EndY = $OriginalHeight; $EndX = $OriginalHeight; } imagecopyresampled($NewImage, $SrcImage, $EndX, $EndY, $StartX, $StartY, $NewImageSize, $NewImageSize, $OriginalWidth, $OriginalHeight); PLease can you help me? Thank you. Quote Link to comment Share on other sites More sharing options...
vinny42 Posted September 23, 2013 Share Posted September 23, 2013 Check your coordinates. The destination coordinates in the new image should be 0,0 to place the pasting action at the top-left corner. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.