figo2476 Posted April 5, 2008 Share Posted April 5, 2008 I have an image and I want to crop portion of the original image. imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) I pass the cropped image size & original image size to the function. The end result is that a smaller image with black spacing around the bottom and right side. Then the original image (it resize itself ugly) to the rest of the area. But if the dst and src are in the same width and height, the end result has no problem. Any hint? Link to comment https://forums.phpfreaks.com/topic/99659-how-to-use-imagecopyresampled-correctly/ Share on other sites More sharing options...
Paperstyle Posted April 5, 2008 Share Posted April 5, 2008 Are the dimensions of source and destination in the same proportions? By that I mean if you divide source_x by source_y and dest_x by dest_y do you get the same result? Link to comment https://forums.phpfreaks.com/topic/99659-how-to-use-imagecopyresampled-correctly/#findComment-509825 Share on other sites More sharing options...
figo2476 Posted April 5, 2008 Author Share Posted April 5, 2008 From my understanding, src_w & src_h are the original width and height. dest_x & dest_y are the dimension I want them to be. "same proportions": em.. users can clip portion from the original image. (The clip functionality I provided). So it is not in same proportions. The end result is users clip the image and it should return that part in original quality. Link to comment https://forums.phpfreaks.com/topic/99659-how-to-use-imagecopyresampled-correctly/#findComment-509834 Share on other sites More sharing options...
tippy_102 Posted April 5, 2008 Share Posted April 5, 2008 Hard to say without seeing your entire code, but here's what I use: <?php // creates a copy of a selected chunk of image.jpg $filename= "image.jpg"; list($w, $h, $type, $attr) = getimagesize($filename); $src_im = imagecreatefromjpeg($filename); $src_x = '0'; // begin x $src_y = '0'; // begin y $src_w = '100'; // width $src_h = '100'; // height $dst_x = '0'; // destination x $dst_y = '0'; // destination y $dst_im = imagecreatetruecolor($src_w, $src_h); $white = imagecolorallocate($dst_im, 255, 255, 255); imagefill($dst_im, 0, 0, $white); imagecopy($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h); header("Content-type: image/png"); imagepng($dst_im); imagedestroy($dst_im); ?> Link to comment https://forums.phpfreaks.com/topic/99659-how-to-use-imagecopyresampled-correctly/#findComment-510126 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.