note 16964 deleted from function.getimagesize by jimw

From: Date: Mon, 10 Dec 2001 23:33:02 +0000
Subject: note 16964 deleted from function.getimagesize by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22477@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...

« previous php.notes (#22477) next »