note 21982 deleted from function.imagecopyresampled by aidan

From: Date: Mon, 04 Oct 2004 09:45:31 +0000
Subject: note 21982 deleted from function.imagecopyresampled by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77969@lists.php.net to get a copy of this message
Note Submitter: thomasNOSPAM at NO_SPAM dot gutschke dot com ---- 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));

« previous php.notes (#77969) next »