|cropping with gd library|
So I have
imagecopyresampled ($dst_image , $src_image, 0, 0, $src_x, $src_y, $new_width, $new_height, $image_width-$src_x, $image_height-$src_y);
src_x and src_y are the co-ordinates I want to crop the image from, but I am not sure how how to create the co-ordinates of where to cut them to - i.e. set the crop height and width. I have been working on this for hours testing every permutation under the sun, and cant figure it out. How is this done?
you'll have to calculate the width and height from the coordinates.
|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 ) |
imagecopyresampled() will take a rectangular area from src_image of width src_w and height src_h at position (src_x,src_y)...
Yes, I have been doing all that but I can't understand how to crop e.g. 50px from the left and 50px from the right, I can just do one or the other, but not both. If I was to crop 50 on each side, what are the two variables I need to adjust by 50?
$src_x would be 50 and$src_w would be ([source image width] - 100)