GamingWarrior Posted October 14, 2007 Share Posted October 14, 2007 Ok, this is driving me crazy. I want to crop: to but all the scripts i find to crop seem to just shrink the image and cut the edges to make it keep the ratio If someone can just tell me where to start i might be able to work it out from there. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/73235-solved-crop-image/ Share on other sites More sharing options...
Barand Posted October 15, 2007 Share Posted October 15, 2007 Do you know the coordinates of the area to crop Anyway, assuming [pre] 60,50 +----------+ | | | | | | +----------+ 120,90 [/pre] <?php $x1 = 60; $y1 = 50; $x2 = 120; $y2 = 90; $w = $x2 - $x1; $h = $y2 - $y1; $dest = imagecreatetruecolor($w, $h); $src = imagecreatefromjpeg ('original.jpg'); imagecopy($dest, $src, 0, 0, $x1, $y1, $w, $h); imagejpeg($dest); imagedestroy($dest); imagedestroy($src); ?> Quote Link to comment https://forums.phpfreaks.com/topic/73235-solved-crop-image/#findComment-369559 Share on other sites More sharing options...
GamingWarrior Posted October 15, 2007 Author Share Posted October 15, 2007 Thanks A heap, works perfect I was looking at it as being a hard and long process when its quite the opposite. Quote Link to comment https://forums.phpfreaks.com/topic/73235-solved-crop-image/#findComment-369727 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.