visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
262 experts, 1140 registered users, 1615 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

We now celebrate our 5 years of existence and break our frequentation records... Here are the stats of those 5 years.

Languages :: PHP :: php and tif


By: roe1and Great Britain  Date: 16/04/2008 12:49:24  English  Points: 20 Status: Answered
Quality : Excellent
i want to use the script below to copy/resize images. will it work with tif images. i've been looking on php.net at all these:
# imagecreate
# imagecreatefromgd2
# imagecreatefromgd2part
# imagecreatefromgd
# imagecreatefromgif
# imagecreatefromjpeg
# imagecreatefrompng
# imagecreatefromstring
# imagecreatefromwbmp
# imagecreatefromxbm
# imagecreatefromxpm
# imagecreatetruecolor

does this mean no support for tif?
the code i'm looking at:

<?php

$source_pic = 'images/source.jpg';
$destination_pic = 'images/destination.jpg';
$max_width = 500;
$max_height = 500;

$src = imagecreatefromjpeg($source_pic);
list($width,$height)=getimagesize($source_pic);

$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;

if( ($width <= $max_width) && ($height <= $max_height) ){
$tn_width = $width;
$tn_height = $height;
}elseif (($x_ratio * $height) < $max_height){
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}else{
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}

$tmp=imagecreatetruecolor($tn_width,$tn_height);
imagecopyresampled($tmp,$src,0,0,0,0,$tn_width, $tn_height,$width,$height);

imagejpeg($tmp,$destination_pic,100);
imagedestroy($src);
imagedestroy($tmp);

?>
By: VGR Date: 17/04/2008 13:56:50 English  Type : Answer
yes, PHP (or, rather, the GD "standard" library )has two TIFF constants but doesn't seem to be able to work on TIFF (tagged-image format)

You should read this PHP GD Manual entry about TIFF and smile ;-)

You'll probably have to install Imagick, which is different (more powerful?) than GD. It shouldn't be a problem, even on Windows

HTH

Do register to be able to answer

 Add This Article To:
 del.icio.usDel.icio.us  diggDigg  googleGoogle  spurlSpurl
 blinkBlink  wongWong  simpySimpy  yahooY! MyWeb 
EContact
browser fav
page generated in 4541.255000 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page