Zmodem commented on a Page, PHP Image Scaler  -  Aug 25, 2008

Would this work (not a big PHP user):

Syntax: image_scale($img,"200","250")

Example:

<?php

$img = 'images/myfiles/image1.jpg';
echo '<img src="' .$img. '" ' .width_scale($img,"200","250"). '>';

?>
//////////////////////////////////////////////////////////////
// Scale images by width+height //
//////////////////////////////////////////////////////////////
function image_scale($file,$maxwidth,$maxheight) {
  list($width,$height) = getimagesize($file);
  if (($width > $maxwidth) && ($height > $maxheight)) {
      $new_width = $maxwidth;
      $new_height = $maxheight;
      $dec_perw = $new_width / $width * 100;
      $dec_perh = $new_height / $height * 100;
      $new_width = $width / 100 * $dec_per;
      $new_height = $height / 100 * $dec_per;
      return 'width="' .$new_width. '" height="' .$new_height. '"';
  }
  else {
      return 'width="' .$width. '" height="' .$height. '"';
  }
}
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.