note 21982 added to function.imagecopyresampled

From: Date: Sun, 02 Jun 2002 21:57:11 +0000
Subject: note 21982 added to function.imagecopyresampled
Groups: php.notes 
Request: Send a blank email to php-notes+get-31353@lists.php.net to get a copy of this message
Just a little code snippet. Use it if you want thumbnails of a given size (= given proportions) from pictures of unknown proportions. It will scale the picture down and, if necessary, will center the copied part inside the created thumbnail. This will result in black borders if the source image has different proportions; You need to define $thumbw and $thumbh as thumbnail-width and -height. I'll use the ImageCopyResampleBicubic-function from the former post. $size = getimagesize($image); $scale = min($thumbw/$size[0], $thumbh/$size[1]); $width = (int)($size[0]*$scale); $height = (int)($size[1]*$scale); $deltaw = (int)(($thumbw - $width)/2); $deltah = (int)(($thumbh - $height)/2); $src_img = ImageCreateFromJPEG($image); $dst_img = ImageCreate($thumbw, $thumbh); ImageCopyResampleBicubic($dst_img, $src_img, $deltaw, $deltah, 0, 0, $width, $height, ImageSX($src_img),ImageSY($src_img)); -- http://www.php.net/manual/en/function.imagecopyresampled.php http://master.php.net/manage/user-notes.php?action=edit+21982 http://master.php.net/manage/user-notes.php?action=delete+21982 http://master.php.net/manage/user-notes.php?action=reject+21982

« previous php.notes (#31353) next »