In PHP, you can use built-in capabilities to convert image files from one extension to another extension. However, multiple page tiff to jpg thumbnail is a tricky one. Following code allows you to convert a multi-page TIFF file to JPG thumbnail. This conversion is usually required in those situations where you have to allow users to view a Fax document on a webpage. Since web browsers usually doesn’t support TIFF extensions. So you have to convert these documents to either JPG or PDF. Following code works for both situations.

  // Saving every page of a TIFF separately as a JPG thumbnail
  $images = new Imagick("testing.tif");
  foreach($images as $i=>$image) {
    // Providing 0 forces thumbnail Image to maintain aspect ratio
    echo "<img src='page$i.jpg' alt='images' ></img>";
catch(Exception $e)
  echo $e->getMessage();
Tagged with: PHPProgrammingSource Code

2 Responses to Converting Multipage TIFF file to JPG/GIF in PHP

  1. shamsuddin says:

    where to get this Imagick function.

  2. sourcecodemania says:

    You’ll need to install ImageMagick extension for PHP.

    Simple way to install ImageMagick on linux centos machine:

    # yum install ImageMagick*
    # pecl install imagick

    # echo “” >> /etc/php.ini
    #service httpd restart

    On windows, you’ll need to install the appropriate image magick from here

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Related News Feeds

Set your Twitter account name in your settings to use the TwitterBar Section.