467,104 Members | 1,065 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,104 developers. It's quick & easy.

is there a code to crop bottom border from an image ?

hi
is there a code to crop bottom border from an image when creating thumbnail for this image without crop the original image , but just crop 15px bottom border for creating the thumbnails for the image ?
Dec 13 '09 #1
  • viewed: 3325
Share:
3 Replies
here is creating thumbnail code it's fitting to the image , can we make it crop 15 pixel from the bottom , i mean can we make it fit the all width & the all heigh minus - 15 pixel ?

Expand|Select|Wrap|Line Numbers
  1. #create thumb
  2. $thumb = gd_fit($image,$settings['thumbxy']);
  3.  
Expand|Select|Wrap|Line Numbers
  1.     function gd_fit(&$image, $target) { 
  2.  
  3.         //takes the larger size of the width and height and applies the  
  4.         //formula accordingly...this is so this script will work  
  5.         //dynamically with any size image 
  6.  
  7.         $width = gd_width($image);
  8.         $height = gd_height($image);
  9.  
  10.         if ($width > $height) { 
  11.             $percentage = ($target / $width); 
  12.         } else { 
  13.             $percentage = ($target / $height); 
  14.         } 
  15.  
  16.         //gets the new value and applies the percentage, then rounds the value 
  17.         $width = round($width * $percentage); 
  18.         $height = round($height * $percentage); 
  19.  
  20.         //returns the new sizes in html image tag format...this is so you 
  21.         //can plug this function inside an image tag and just get the 
  22.  
  23.         return gd_resize($image,$width,$height);
  24.  
  25.     } 
Dec 13 '09 #2
You can also use the funcion imagecopyresampled() from the GD lib.

http://php.net/manual/en/function.im...yresampled.php

-------------------------------------
xatcom.net, diseño web
Dec 15 '09 #3
Thanks for reply Dear Carmarri

Greetings
Dec 15 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Kevin Smith | last post: by
2 posts views Thread by Michael Winter | last post: by
6 posts views Thread by John Salerno | last post: by
1 post views Thread by donpro | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.