note 66277 added to function.imagecopyresized
| From: | maccelo at gmail dot com | Date: | Thu, 18 May 2006 10:29:58 +0000 |
| Subject: | note 66277 added to function.imagecopyresized | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111571@lists.php.net to get a copy of this message | ||
Si quieres resizar tu imagen estableciendo un máximo ancho y alto permitidos conservando el
asepcto, tengo una función muy sencilla que lo hace ... espero que a alguien le sirva saludos.
<?
$tamagno = getimagesize("images_sample.jpg");
$width = $tamagno[0];
$height = $tamagno[1];
$max_width = 272;
$max_height = 204;
if ( $width >= $height){
$ancho = $max_width;
$factor = (($max_width * 100) / $width)/100;
$alto = $height * $factor;
if ($alto > $max_height){
$factor = (($max_height * 100) / $height)/100;
$ancho = $width * $factor;
$alto = $max_height;
}
} else {
$alto = $max_height;
$factor = (($max_height * 100) / $height)/100;
$ancho = $width * $factor;
if ($ancho > $max_width){
$factor = (($max_height * 100) / $width)/100;
$alto = $height * $factor;
$ancho = $max_width;
}
}
echo "<img src='image_sample.jpg' height='".$alto."'
width='".$ancho."' alt='' />"
?>
----
Server IP: 200.73.8.42
Probable Submitter: 200.113.92.222
----
X-Spam-Status: Yes, hits=9.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HEAD_ILLEGAL_CHARS,HTML_IMAGE_ONLY_06,HTML_MESSAGE autolearn=no
version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.imagecopyresized.php
Edit -- http://master.php.net/note/edit/66277
Del: integrated -- http://master.php.net/note/delete/66277/integrated
Del: useless -- http://master.php.net/note/delete/66277/useless
Del: bad code -- http://master.php.net/note/delete/66277/bad+code
Del: spam -- http://master.php.net/note/delete/66277/spam
Del: non-english -- http://master.php.net/note/delete/66277/non-english
Del: in docs -- http://master.php.net/note/delete/66277/in+docs
Del: other reasons-- http://master.php.net/note/delete/66277
Reject -- http://master.php.net/note/reject/66277
Search -- http://master.php.net/manage/user-notes.php