peuge Posted March 9, 2009 Share Posted March 9, 2009 Hey all, So I have a picture and when I click on it a crop box appear and I select the area I want to crop from the picture. Once this is done I click the crop button and that sends the co-ordinates of my selection via JSON to a php file found below. I have checked that all the values that are being sent are correct. My problem is that when I crop it does not crop it instead zooms into the picture. I am new to GD but could anyone please help. Thanks. I have also tried all the other imagecopy commands and they dont work. header('Content-Type: image/png'); $coords = json_decode(stripslashes($_GET['coOrds'])); $filename = "beach.png"; //The values below are from the crop box used on the original picture ($filename) $x1 = $coords[0];//top left hand corner $y1 = $coords[1];//top right hand corner $x2 = $coords[2];// bottom right corner $y2 = $coords[3];//bottom right corner $width = $coords[4]; $height = $coords[5]; $canvSize = getimagesize($filename); //size of original picture $source = imagecreatefrompng($filename); $newImg = imagecreatetruecolor($width,$height); imagecopyresampled($newImg, $source, 0,0, $x1, $y1, $width, $height, $width, $height); imagepng($newImg); Link to comment https://forums.phpfreaks.com/topic/148604-help-with-cropping-images-using-gd-lib/ Share on other sites More sharing options...
DjMikeS Posted March 9, 2009 Share Posted March 9, 2009 I think you should use imagecopymerge(); http://uk3.php.net/manual/en/function.imagecopymerge.php Link to comment https://forums.phpfreaks.com/topic/148604-help-with-cropping-images-using-gd-lib/#findComment-780412 Share on other sites More sharing options...
peuge Posted March 10, 2009 Author Share Posted March 10, 2009 None of the imagecopy* functions work. I did not try imagecopymerge before, but it also does not work. Does anyone know why this might be? What basically happens is it just zooms in on the portion of picture I have selected and puts it into the destImg? All I want to do is take a part of an image and put it into another image. Any help appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/148604-help-with-cropping-images-using-gd-lib/#findComment-780956 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.