Page 1 of 1

php question

Posted: 2008-04-02T07:35:40-07:00
by nonaguy
I am building an application for viewing 60,000+ images. These images are all stored as tiffs. What I would like to do is in my application, someone uses a form to select whatever image they wish to view, and I would like to run a php script that would convert the tiff to jpeg and resize it to thumbnail size and echo the jpeg out to the viewer.

In other words, I want to load the tiff in memory, convert and resize in memory, and echo out the result, without writing anything to the original image. I am somewhat new to php and I would appreciate any help you can provide. Thank you.

Re: php question

Posted: 2008-04-02T09:06:10-07:00
by Bonzo
You can check my site for examples of IM and php.

Check this page for displaying an image without saving it: http://www.rubblewebs.co.uk/imagemagick ... isplay.php

This is the code you can use; it can be simplified if you are always using the same dimensions.

Code: Select all

<?php
$photo="../code/sunflower.jpg";
$THUMB_SZ  = 125;
$THUMB_PRESZ  = $THUMB_SZ * 2;
$QUALITY = 87;
$cmd = "convert -size $THUMB_PRESZ".'x'."$THUMB_PRESZ \"$photo\"" .
" -resize $THUMB_SZ".'x'."$THUMB_SZ" .
" -strip" .
" -unsharp 0.2x0.6+1.0" .
" -quality $QUALITY JPG:-";

header("Content-type: image/jpeg");
passthru($cmd, $retval);
?>

Re: php question

Posted: 2008-04-04T07:14:40-07:00
by nonaguy
Thank you, the code works great for what we need it to do.