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

  • SEARCH
  • Home
  • 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 9124365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:33:20+00:00 2026-06-17T06:33:20+00:00

I have a PHP application which needs to deal with incoming TIFF files. I

  • 0

I have a PHP application which needs to deal with incoming TIFF files. I have neither control nor knowledge over the colorspaces of this TIFFs and the application should store all incoming images as RGB JPEGs.

Problem is, incoming TIFF files are anything: CMYK, RGB, some sort of YCbCr wrapped in sRGB, and so on, and I need to convert them somehow to RGB JPEGs before saving.

I need some sort of a conversion function in PHP which uses IMagick extension which can get any binary TIFF data and convert it to proper RGB JPEG binary data. It needs to handle different colorspaces inside TIFF images correctly. Output format (RGB JPEG) stays the same for any input file.

The following obvious solution converts some CMYK TIFFs correctly, some CMYK TIFFs get inverted colors and YCbCr RGB TIFFs get totally corrupted by red overlay:

$converter = new IMagick();
$converter->setResourceLimit(6, 1);
$converter->readImageBlob($data);

if ($converter->getImageColorspace() != IMagick::COLORSPACE_RGB
    && $converter->getImageColorspace() != IMagick::COLORSPACE_GRAY
) {
    $icc_rgb = file_get_contents('sRGB_v4_ICC_preference.icc');
    $converter->profileImage('icc', $icc_rgb);
    $converter->setImageColorspace(IMagick::COLORSPACE_RGB);
}

$converter->setImageFormat('jpeg');
$converter->setImageCompression(Imagick::COMPRESSION_JPEG);
$converter->setImageCompressionQuality(60);

$converter->resizeImage(1000, 1000, IMagick::FILTER_LANCZOS, 1, true);
$converter->stripImage();

$result = $converter->getImagesBlob();

This solution is taken from there: http://blog.rodneyrehm.de/archives/4-CMYK-Images-And-Browsers-And-ImageMagick.html Obviously, it doesn’t work for all colorspaces, because it doesn’t detect them reliably. As you can see, it even uses the sRGB_v4 ICC color profile downloaded from it’s homepage.

Google finds me one particular solution to the red overlay problem (just one of the conversion screw-ups), but it’s only for console and when you know beforehand that you deal with YCbCr images:

convert some.tif -set colorspace YCbCr -colorspace RGB some.jpg

I can live with passthru-ing convert and pass to convert all the magical switches needed, but I suppose I need to detect the source image’s colorspace beforehand and call a identify | grep before every convert in an otherwise PHP application is an overkill.

  • 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-17T06:33:22+00:00Added an answer on June 17, 2026 at 6:33 am

    I’ve experienced this same issue.
    It also came up in the imagick forums and the correction was pushed into ImageMagick 6.8.0-4 .

    So upgrading should solve this issue. I’ve upgraded to ImageMagick 6.8.1-9 and haven’t encountered this since.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a php web application which needs to open pdf files in
I am using Google GeoCoding services. I have a PHP application which calls the
I have written a PHP application which requires storage of millions of integers between
I have a custom built application framework written in PHP which I have been
I have a PHP based web application which is currently only using one webserver
We have a web application which has been developed over the past 7 months.
I have a PHP application that needs to generate some PDF invoices and PDF
I have a php file which needs to be executed in CLI from my
We have a web application which needs to store uploaded images with EdgeCast or
I'm writing a web application in PHP which needs to store images and image

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.