note 66277 deleted from function.imagecopyresized by bjori

From: Date: Thu, 18 May 2006 10:32:07 +0000
Subject: note 66277 deleted from function.imagecopyresized by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-111572@lists.php.net to get a copy of this message
Note Submitter: maccelo at gmail dot com Reason: non-english ---- 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='' />" ?>

« previous php.notes (#111572) next »