comptech520
08-26-2008, 01:22 PM
Does anyone know any good scripts to create thumbnails from an orignial image, and cache it in a different directory?
Thanks
Thanks
|
Click to See Complete Forum and Search --> : Cacheing Images comptech520 08-26-2008, 01:22 PM Does anyone know any good scripts to create thumbnails from an orignial image, and cache it in a different directory? Thanks NogDog 08-26-2008, 01:48 PM See imagecopyresampled (http://www.php.net/imagecopyresampled)(). gersompie 08-27-2008, 07:52 AM Written by myself :) $max_height_or_width = 120; // in pixels $photo_name = '123456.jpg'; $full_path_photo = 'path to big-photodirectory/'.$photoname; $full_path_thumb = 'path to thumbdirectory/'.$photoname; $src_img = imagecreatefromjpeg( $full_path_photo ); $sizesrc = getimagesize( $full_path_photo ); if ($sizesrc[0] > $sizesrc[1]) { $dest_x = $max_height_or_width; $factor = $sizesrc[0]/$max_height_or_width; $dest_y = $sizesrc[1]/$factor; } else { $dest_y = $max_height_or_width; $factor = $sizesrc[1]/$max_height_or_width; $dest_x = $sizesrc[0]/$factor; } $dst_img = imagecreatetruecolor($dest_x, $dest_y); imagecopyresampled( $dst_img, $src_img, 0, 0, 0, 0, $dest_x, $dest_y, $sizesrc[0], $sizesrc[1] ); imagejpeg( $dst_img, $full_path_thumb ); imagedestroy( $src_img ); imagedestroy( $dst_img ); webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |