phillip: thumb function

Beitrag lesen

ih habs :)

function thumb ($source, $dest)
  {
   $img_width   = 150;
   $img_height  = 150;

$image = imagecreatefromjpeg($source);

list($src_width, $src_height) = getimagesize($source);

if($src_width >= $src_height)
     {
      $new_image_width = $img_width;
      $new_image_height = $src_height * $img_width / $src_width;
     }
    if($src_width < $src_height)
     {
      $new_image_height = $img_width;
      $new_image_width = $src_width * $img_height / $src_height;
     }

echo $new_image_height;
   echo $new_image_width;

$new_image = imagecreatetruecolor($new_image_width, $new_image_height);
   imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width,$new_image_height, $src_width, $src_height);
   imagejpeg($new_image, $dest, 100);
  }