By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,581 Members | 2,007 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,581 IT Pros & Developers. It's quick & easy.

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

P: 56
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
Share this Question
Share on Google+
3 Replies


P: 56
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

P: 5
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

P: 56
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.