Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9128339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:29:30+00:00 2026-06-17T07:29:30+00:00

I have a server which holds TIFF images. Most clients can read and display

  • 0

I have a server which holds TIFF images. Most clients can read and display TIFF images, so there’s no problem. However, some clients can’t handle this format but can handle JPG.
I thought of using PHP’s GD library to do a server side conversion for clients without TIFF reading abilities. But I noticed GD can’t read TIFF files too.

Imagick not working in windows, My idea was to create an imageFetcher.php which gets as a parameter the actual image the client wants. It checks the client’s type and if needed converts the image and outputs a JPG, otherwise it simply outputs the TIFF.

does anyone have any idea on how I could do such a thing?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:29:31+00:00Added an answer on June 17, 2026 at 7:29 am

    In the forum at http://www.php.net/gd the following comment is written:

    IE doesn’t show TIFF files and standard PHP distribution doesn’t support converting to/from TIFF.

    ImageMagick (http://www.imagemagick.org/script/index.php) is a free software that can read, convert and write images in a large variety of formats. For Windows users it includes a PHP extension php_magickwand_st.dll (and yes, it runs under PHP 5.0.4).

    When converting from TIFF to JPEG, you must also convert from CMYK color space to RGB color space as IE can’t show CMYK JPGs either. Please note:
    -TIFF files may have RGB or CMYK color space
    -JPEG files may have RGB or CMYK color space

    Here are example functions using ImageMagick extension:
    – convert TIFF to JPEG file formats
    – convert CMIK to RGB color space
    – set image resolution to 300 DPIs (doesn’t change image size in pixels)

    <?php
    
    function cmyk2rgb($file) {
        $mgck_wnd = NewMagickWand();
        MagickReadImage($mgck_wnd, $file);
    
        $img_colspc = MagickGetImageColorspace($mgck_wnd);
        if ($img_colspc == MW_CMYKColorspace) {
            echo "$file was in CMYK format<br />";
            MagickSetImageColorspace($mgck_wnd, MW_RGBColorspace);
        }
        MagickWriteImage($mgck_wnd, str_replace('.', '-rgb.', $file));
    }
    
    function tiff2jpg($file) {
        $mgck_wnd = NewMagickWand();
        MagickReadImage($mgck_wnd, $file);
    
        $img_colspc = MagickGetImageColorspace($mgck_wnd);
        if ($img_colspc == MW_CMYKColorspace) {
            echo "$file was in CMYK format<br />";
            MagickSetImageColorspace($mgck_wnd, MW_RGBColorspace);
        }
        MagickSetImageFormat($mgck_wnd, 'JPG' );
        MagickWriteImage($mgck_wnd, str_replace('.tif', '.jpg', $file));
    }
    
    function to300dpi($file) {
        $mgck_wnd = NewMagickWand();
        MagickReadImage($mgck_wnd, $file);
        $img_units = MagickGetImageUnits($mgck_wnd);
        switch ($img_units) {
            case MW_UndefinedResolution: $units= 'undefined'; break;
            case MW_PixelsPerInchResolution: $units= 'PPI'; break;
            case MW_PixelsPerCentimeterResolution: $units= 'PPcm'; break;
        }
        list($x_res, $y_res) = MagickGetImageResolution($mgck_wnd);
        echo "$file<br /> x_res=$x_res $units - y_res=$y_res $units<br />";
        if($x_res == 300 && $y_res == 300 && $img_units == MW_PixelsPerInchResolution) {return; }
        MagickSetImageResolution($mgck_wnd, 300 , 300);
        MagickSetImageUnits($mgck_wnd, MW_PixelsPerInchResolution);
        MagickWriteImage($mgck_wnd, str_replace('.', '-300.', $file));
    }
    
    $file='photos/test-cmyk.tif';
    //this is a TIFF file in CMYK format with a 96 DPI resolution
    
    cmyk2rgb($file);
    $file = str_replace('.', '-rgb.', $file);
    
    to300dpi($file);
    $file = str_replace('.', '-300.', $file);
    
    tiff2jpg($file);
    $file = str_replace('.tif', '.jpg', $file);
    
    to300dpi($file);
    /* no file name changes as ImageMagick reports 300 DPIs
    $file = str_replace('.', '-300.', $file);
    */
    
    list($width, $height, $type, $attr) = getimagesize($file);
    $width = $width/3;
    $height = $height/3;
    echo "<img src=\"http://localhost/$file\" width=\"$width\" height=\"$height\" alt=\"getimagesize() example\" />";
    echo "<br />$file => width=$width - height=$height - type=$type - attr=$attr<br /><br />";
    
    $file='photos/test-rgb.tif';
    //this is a TIFF file in RGB format with a 96 DPI resolution
    
    cmyk2rgb($file);
    $file = str_replace('.', '-rgb.', $file);
    
    to300dpi($file);
    $file = str_replace('.', '-300.', $file);
    
    tiff2jpg($file);
    $file = str_replace('.tif', '.jpg', $file);
    
    to300dpi($file);
    /* no file name changes as ImageMagick reports 300 DPIs
    $file = str_replace('.', '-300.', $file);
    */
    
    list($width, $height, $type, $attr) = getimagesize($file);
    $width = $width/3;
    $height = $height/3;
    echo "<img src=\"http://localhost/$file\" width=\"$width\" height=\"$height\" alt=\"getimagesize() example\" />";
    echo "<br />$file => width=$width - height=$height - type=$type - attr=$attr<br /><br />";
    
    ?>
    

    Note – Although ImageMagick correctly sets JPEG files resolution to 300 DPIs, some programs might not notice it.

    ELSE

    Use the “imagick” PECL extension

    http://pecl.php.net/package/imagick

    http://php.net/manual/en/book.imagick.php

    Depending on sources and destinations (files? urls? http response?) you’ll do something like:

     $image = new Imagick('something.tiff');
        $image->setImageFormat('png');
        echo $image;
    

    OR

    $image->writeImage('something.png');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a c++ server which is using boost::asio to do read/write operations -
I have a web server which is protected behind http-basic-auth. I've read through the
I have a table in sql server 2005 which holds an ip range and
We have a push notification server which holds the data (device tokens) for several
I have created a table in sql server which holds names of tables in
I have some files in ~Content/Documents folder which holds every uploaded file. In my
In a SQL Server 2000 DB, I have a table which holds string representations
I have a gallery which holds a large number of thumbnail images and I
I have an untyped XML column in Sql Server Database which holds values such
I have an asp.net web app which holds its data in an sql server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.