note 97564 modified in function.getimagesize by danbrown

From: Date: Mon, 26 Apr 2010 14:28:51 +0000
Subject: note 97564 modified in function.getimagesize by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-168648@lists.php.net to get a copy of this message
A simple method to resize a image keeping the constraint proportions: <?php // Constraints $max_width = 100; $max_height = 100; list($width, $height) = getimagesize($img_path); $ratioh = $max_height/$height; $ratiow = $max_width/$width; $ratio = min($ratioh, $ratiow); // New dimensions $width = intval($ratio*$width); $height = intval($ratio*$height); ?> --was-- <? // A simplest method to resize a image keeping the constraint proportions // Constraints $max_width = 100; $max_height = 100; list($width, $height) = getimagesize($img_path); $ratioh = $max_height/$height; $ratiow = $max_width/$width; $ratio = min($ratioh, $ratiow); // New dimensions $width = intval($ratio*$width); $height = intval($ratio*$height); ?> http://php.net/manual/en/function.getimagesize.php

« previous php.notes (#168648) next »