Hey, I'm not sure if anyone ever answered your question, but here's a little 
function I wrote for something similar to what you want to do and it doesn't 
require GD be installed.  You need to modify the top portion, I just threw 
that in there to show you how it would work.  $pic is the name of the image 
you want to display.  $largestside is the largest width/height you'll want to 
be shown - So if the max height or width is supposed to only be 200, you'd 
set it to that, then it scales the other side so that it displays with the 
correct dimensions.  This doesn't ACTUALLY resize the file, it just takes the 
image and then in HTML it sets the height and width.  If you need to actually 
resize the file you will need GD to be installed.  Hope this helps in some 

$pic = "image.jpg";
$dimensions = resize($pic);     
echo "<img src=\"$pic\" width=\"$dimensions[0]\" height=\"$dimensions[1]\">

function resize($v_pic) {

   $largestside = 120;
   $size = GetImageSize ("$v_pic");

   $width = $size[0];
   $height = $size[1];

   if ($width == $height) {
      $dimensions[0] = $largestside;
      $dimensions[1] = $largestside;
   } elseif ($width > $height) {
      $divisor = $width / $largestside;
      $height = $height / $divisor;
      $dimensions[1] = intval ($height);
      $dimensions[0] = $largestside;
   } elseif ($width < $height) {
      $divisor = $height / 120;
      $width = $width / $divisor;
      $dimensions[0] = intval ($width);
      $dimensions[1] = 120;

   return $dimensions;

On Saturday 16 March 2002 04:56 am, you wrote:
> Hi,
> I'm trying to resize images from a big image to smaller image in
> dimension and also file size so that when a user upload an image into
> server, when a browser display the picture it desn't have to be as big.
> I hope my question make sense.
> I just don't know where to start.
> may be somebody could help me, please.
> thank you for reviewing my email.
> regards,
> Dani

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to