Isset1988 Posted June 20, 2012 Share Posted June 20, 2012 Hello guys, I want to crop an image hi.png/.gif/.jpg which is on the root folder, after that i want auto upload it to the root/images folder. I use the above code but i dont have any results. Can you help me? :confused: $src = imagecreatefrompng('hi.png'); $dest = imagecreatetruecolor(648,432); imagecopy($dest, $src, 0, 0, 20, 13, 80, 40); Link to comment https://forums.phpfreaks.com/topic/264497-crop-and-upload-image/ Share on other sites More sharing options...
litebearer Posted June 20, 2012 Share Posted June 20, 2012 Perhaps these may help... crop an image - http://www.nstoia.com/sat/crop/ resize an image - http://www.nstoia.com/sat/resize/ add a drop shadow - http://www.nstoia.com/sat/dropShadow/ Link to comment https://forums.phpfreaks.com/topic/264497-crop-and-upload-image/#findComment-1355458 Share on other sites More sharing options...
Isset1988 Posted June 20, 2012 Author Share Posted June 20, 2012 Thank u for the quick reply. Maybe, with some copy-paste solve my problem. Any other idea? Where i make the mistake? Thank U! Link to comment https://forums.phpfreaks.com/topic/264497-crop-and-upload-image/#findComment-1355481 Share on other sites More sharing options...
Isset1988 Posted June 20, 2012 Author Share Posted June 20, 2012 I Follow your instruction in my custom php page. The result is this: The code is: <?php $old_image='hi.gif'; $full_old='hi.gif'; $full_new='hey.jpg'; $ext = pathinfo($full_old, PATHINFO_EXTENSION); $ext = strtolower($ext); $width=648; $height=432; $x=250; $y=50; $canvas = imagecreatetruecolor( $width, $height ); /* Create a new image in the memory from the file according to file type */ /* IF you add more file types, be sure to add them to the switch statement */ switch ($ext) { case "jpg": case "jpeg": $cropped = imagecreatefromjpeg( $old_image ); break; case "gif": $cropped = imagecreatefromgif( $old_image ); break; case "png": $cropped = imagecreatefrompng( $old_image ); break; default: exit(); break; } /* create the cropped image */ imagecopy( $canvas, $cropped, 0,0, $x, $y, $size[0], $size[1]); // Save the cropped image as cropped.jpg imagejpeg( $canvas, $full_new, 100 ); ?> Can anyone help me? Link to comment https://forums.phpfreaks.com/topic/264497-crop-and-upload-image/#findComment-1355527 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.