susanBuck Posted September 26, 2007 Share Posted September 26, 2007 Ive built a cropper in flash ... here's a screencast of it working in action : http://www.screencast.com/users/susanBuck/folders/Jing/media/3ab9dde4-6b20-4e68-bf15-3559a86b8824 and below is a final still screenshot with all sorts of notes on it for the sake of this question. So the cropper works fine, but flash can't actually edit images, as we all know. So im going to use php gd on the server to do that. So what happens is the user uses the flash interface, and when they're done they click "done" and flash sends variables over to php (the origin of the cropper, the width, the height, what the final image should be, etc etc)... Php uses those variables and using imagecopyresampled, makes the real change on the image. my problem is, I cant quite get the math right in my imagecopyresampled variables $destinationX = ?; $destinationY = ?; $destinationWidth = ?; $destinationHeight = ?; $sourceX = ?; $sourceY = ?; $sourceWidth = ?; $sourceHeight = ?; imagecopyresampled($thumb, $source, $destinationX, $destinationY, $sourceX, $sourceY, $destinationWidth, $destinationHeight, $sourceWidth, $sourceHeight); Anyone have a clear enough understanding of imagecopyresampled to figure this out? Quote Link to comment https://forums.phpfreaks.com/topic/70794-an-imagecopyresampled-cropping-challenge/ Share on other sites More sharing options...
darkfreaks Posted September 26, 2007 Share Posted September 26, 2007 i dont understand your problem? maybe try something like? <?php // The file $filename = 'test.jpg'; $percent = 0.5; // Content type header('Content-type: image/jpeg'); // Get new dimensions list($width, $height) = getimagesize($filename); $new_width = $width * $percent; $new_height = $height * $percent; // Resample $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // Output imagejpeg($image_p, null, 100); ?> Quote Link to comment https://forums.phpfreaks.com/topic/70794-an-imagecopyresampled-cropping-challenge/#findComment-355955 Share on other sites More sharing options...
susanBuck Posted September 26, 2007 Author Share Posted September 26, 2007 i understand how to use imagecopyresampled, and am not looking for all the generic code to do a resizing... i guess the tricky part of what im doing is because not only am i taking a selection of an image, but im taking it and then shrinking it / enlarging it to match a predetermined size. Quote Link to comment https://forums.phpfreaks.com/topic/70794-an-imagecopyresampled-cropping-challenge/#findComment-356008 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.