Kenny - you will find there are no native PHP handlers for TIFF.

If you're on a unix system you'll be able to use the imagemagick function 'convert' at a command line to do this. Something like this I developed for a client will work, you'll need to look up the passthru function in the PHP manual. This is an advanced technique, I'm not planning on discussing it in detail so you'll need to figure out how to get it to work on your own system. Please don't mail me saying 'it doesn't work'.

$binpath is the path to the system binaries, often /usr/bin. You're using the 'convert' command whlch you'll need to read up on in the imagemagick documentation, there's no space to put it here as it's very extensive in what image formats it can convert. PNG, PSD, GIF and other formats are also available.

In this case, $image_handle->username was just a user object which I used as part of the file name for the created file, as was $imgid. The file name ends in .jpeg in this case, convert decides what to convert to by the file extension of the created file name you give it.

passthru("$binpath/convert -quality 100 tiff:$filename $temppath".$image_handle->username.$imgid."jpeg",$imageraw);
while (! is_file("$imgdir/".$image_handle->username.$imgid."jpeg") && filesize("$temppath".$image_handle->username.$imgid."jpeg")==0) {
// Wait 0.2s increments for image creation to complete (if system is slow)
if ($i >= 25) { // 5 seconds elapsed, still no file created

You'll need to check to see if the created file is available after a few milliseconds as this is an out-of-band process, that is PHP can't know when the convert has finished in the case of a very large TIFF, So it polls the directory for the file becoming available. Clearstatcache is needed to purge the cached directory information, otherwise the loop will lock out assuming the file is never there. It breaks the loop at 5 seconds anyway if a hang has occurred.


At 02:46 30/06/2004 +0000, you wrote:
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Subject: Re: [PHP-DB] Image Resize

Kenny wrote:

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
tiff is not good graficformat. The browsers arenī t able to display this. Some browsers, f. e. IE
are not able to display the PNG-format always properly. The best you take only jpg. The snipplet
you send seams to work.


CaptionKit : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.

VideoChat with friends online, get Freshly Toasted every
day at : NetMeeting solutions
for a connected world.

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to