NYCPHP Meetup

NYPHP.org

[nycphp-talk] Creatings Thumbnails with GD

Russ Demarest rsd at electronink.com
Wed Nov 23 13:31:32 EST 2005


This works for me but I have limited needs.

         $width = imagesx($img);
         $height = imagesy($img);

         if ( $width > $height ){
                 $ratio = $tw / $width;
         }else{
                 $ratio = $th / $height;
         }
         $newWidth = $width * $ratio;
         $newHeight = $height * $ratio;

         $rimg = imagecreatetruecolor($newWidth,$newHeight);
         imagecopyresampled($rimg,$img,0,0,0,0,$newWidth,$newHeight, 
$width,$height);

         imagejpeg($rimg,$thumb);

         imagedestroy($img);
         imagedestroy($rimg);



Good Luck

On Nov 23, 2005, at 1:25 PM, Jeff Loiselle wrote:

> I am working on a new project, which is hosted on a server w/o
> ImageMagick (^@#%#^).. So I am forced to use GD to create
> thumbnails... Anyone got any examples? Jeff Knight are you out there?
> ;-) Anyone? Bueller? Bueller?
>
> ---
> Jeff Loiselle
> Web Developer, Musician, and Observer
> http://jeff.loiselles.com
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
>




More information about the talk mailing list