imagecopyresampled to resize and crop an image - not returning the expected result
Posted
by
David
on Stack Overflow
See other posts from Stack Overflow
or by David
Published on 2011-01-08T01:59:41Z
Indexed on
2011/01/08
2:53 UTC
Read the original article
Hit count: 252
imagecopyresized ( 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 )
This is what I want to do: I have an image that's 600x1000px in size, and I want to create a thumb that's 100x100px after resizing that image to 300x500px, the x coordinate for the top left point of the thumb square should be at 100(src x) and 120(src y).
According to what I understand from the manual, the command should be
$dst_image = imagecreatetruecolor(100,100);
$src_image = imagecreatefromjpeg('/home/sandbox/imagetoresize.jpg');
imagecopyresized ($dst_image, $src_image, 0, 0, 100, 120, **300 , 500 , 600 , 1000** )
It is cropping the image just fine, but it isn't resizing it correctly. I never got it to match what I see in my image editor (the GIMP). What am I doing wrong? I confirmed that all the numbers are correct, but it's always shifted up or down no matter what I do.
Your help would really be appreciated!
© Stack Overflow or respective owner