Image Resize

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,
 
Does anyone know if you can resize a tif image?
I have created a photo gallery and the client want to be able to upload
Jpeg and Tiff files, Unfortunately I have never worked with Tiff
 
Here is my code for Jpg files, But tiff has me stumped
 
<?php
  $extra_path = "";
  if ($mode == "small") {
    $thumbnailsize = 100;
  } else if ($mode == "med") {
    $thumbnailsize = 140;
  } else if ($mode == "large") {
    $thumbnailsize = 200;
  } else if ($mode == "smalladmin") {
    $thumbnailsize = 150;
    $extra_path = "../";
  }
 
  $path = $extra_path . "data/$file";
  $img = ImageCreateFromJPEG($path);
  $originalX = imagesx($img);
  $originalY = imagesy($img);
  if ($originalX > $originalY) {
    $sf = (double) $thumbnailsize / $originalX;
  } else {
    $sf = (double) $thumbnailsize / $originalY;
  }
  $neww = $originalX * $sf;
  $newh = $originalY * $sf;
 $tn = ImageCreateTrueColor($neww, $newh); //ImageCreate
  ImageCopyResampled($tn, $img, 0,0,0,0, $neww, $newh, $originalX,
$originalY); //ImageCopyResized
  Header("Content-Type: image/jpeg");
  ImageJPEG($tn);
  ImageDestroy($tn);
  ImageDestroy($img);
?>
 
K-

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux