note 16964 added to function.getimagesize

From: Date: Tue, 20 Nov 2001 15:46:20 +0000
Subject: note 16964 added to function.getimagesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-21063@lists.php.net to get a copy of this message
In the example above you could be left with an image that is wider than your $max_width. A better function would be the following: function doScaleFoto($srcFoto, $theSize){ $srcX = ImageSX ( $srcFoto ); $srcY = ImageSY ( $srcFoto ); $xFactor = $theSize['x']/$srcX; $yFactor = $theSize['y']/$srcY; if ( $xFactor < $yFactor ){ $fact = $xFactor; } else{ $fact = $yFactor; } $newX = $srcX * $fact; $newY = $srcY * $fact; $dstImg = ImageCreateTrueColor ( $newX, $newY ); ImageCopyResampled ( $dstImg, $srcFoto, 0, 0, 0, 0, $newX, $newY, $srcX, $srcY ); return $dstImg; } where $theSize is an array containing your max values for x(width) and y(height) and $sorceFoto is an image created with ImageCreatFrom... -- http://www.php.net/manual/en/function.getimagesize.php http://master.php.net/manage/user-notes.php?action=edit+16964 http://master.php.net/manage/user-notes.php?action=delete+16964 http://master.php.net/manage/user-notes.php?action=reject+16964

« previous php.notes (#21063) next »