homepage Welcome to WebmasterWorld Guest from 54.211.231.221
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
cropping with gd library
whatson




msg:4558481
 1:43 am on Mar 26, 2013 (gmt 0)

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?

 

phranque




msg:4558553
 11:32 am on Mar 26, 2013 (gmt 0)

you'll have to calculate the width and height from the coordinates.

http://php.net/manual/en/function.imagecopyresampled.php [php.net]:
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)...

whatson




msg:4558691
 7:03 pm on Mar 26, 2013 (gmt 0)

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?

phranque




msg:4558728
 9:28 pm on Mar 26, 2013 (gmt 0)

$src_x would be 50 and$src_w would be ([source image width] - 100)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved