Hi,

Wednesday, April 20, 2005, 12:39:54 AM, you wrote:
TDJ> Is there a quick way to convert a TIFF format picture to a GIF quickly? I
TDJ> can only find support for GIFs in PHP, but maybe I'm missing something. I
TDJ> have a client running a photography business, and I have designed an image
TDJ> watermark and resizing engine, and a server to check the request, serve the
TDJ> file, and then delete it. I mainly made this to help him run the site
TDJ> himself, since he isn't very good with Photoshop, and can't watermark the
TDJ> images (I shouldn't say that...he probably could, but not very fast....but
TDJ> anyway...).
TDJ>  This is all working fine and dandy, but the system will only accept GIF
TDJ> format. His images are all raw scans in TIFF format. This means that he has
TDJ> to open the image in Photoshop, resize it, and convert it to a GIF. I think
TDJ> he can do this himself, but I'd like to make it even simpler, which is why
TDJ> I'm writing.
TDJ>  I need a quick way, preferably in PHP, but it doesn't have to be, to
TDJ> convert large batches of TIFF format images to GIF. Does anyone know of a
TDJ> way to do this?
TDJ>  Thanks for reading, and for your responses in advance...


I use netpbm for conversion to png from tiffs and windows bitmaps like this:

//$tempname from fileupload tmpname
//$file from fileupload name
$jobpath = '/wherever/you/want/files/stored';
if($im = getimagesize($tempname)){
  if($im[0] > 0){
    //cleanup filename  
    $file = ereg_replace("'","",$file);
    $file = ereg_replace("%20","_",$file);
    $file = ereg_replace(" ","_",$file);
    $ext = @substr($file, (@strrpos($file, ".") ? @strrpos($file, ".") + 1 : 
@strlen($file)), @strlen($file));
    $fname = basename($file,$ext);
    switch(intval($im[2])){
      case 7:
      case 8:
        //force a tif extension for netpbm
        $tfilename = $jobpath.'/'.$fname.'tif';
        move_uploaded_file($tempname, $tfilename);
        $file = $fname.'png';
        $filename = $jobpath.'/'.$file;
        shell_exec ("/path/to/netpbm/bin/tifftopnm -quiet $tfilename | 
/path/to/netpbm/bin/pnmtopng > $filename");
      break;
      case 6:
        //force a bmp extension for netpbm    
        $tfilename = $jobpath.'/'.$fname.'bmp';
        move_uploaded_file($tempname, $tfilename);
        $file = $fname.'png';
        $filename = $jobpath.'/'.$file;
        shell_exec ("/path/to/netpbm/bin/bmptoppm -quiet $tfilename | 
/path/to/netpbm/bin/pnmtopng > $filename");
      break;
      default:
        $filename = $jobpath.'/'.$file;
        move_uploaded_file($tempname, $filename);
      break;
    }
  }
}

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to