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 8340225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:07:18+00:00 2026-06-09T05:07:18+00:00

I made a tool where people can upload photos and modify them, including desaturation,

  • 0

I made a tool where people can upload photos and modify them, including desaturation, resulting in a greyscale image.
I generate the final image using PHP’s GD library.

When printing these images the colors appear wrong so using Image Magick I add a color profile.

This works great except for images that have been greyscaled. The color profile gets added, but when I open the image in Photoshop, it says “The embedded ICC profile cannot be used because the ICC profile is invalid. Ignoring the profile”.
In Photoshop the image is set to Greyscale rather than RGB, hence the attached RGB profile is wrong. I need it to be RGB.

I’m using the following code to add all the possible information in an attempt to make the image RGB:

<?php
$i = new Imagick();
$i->readimage('image.jpg');
$i->setimagetype(Imagick::IMGTYPE_TRUECOLOR);
$i->setimagecolorspace(Imagick::COLORSPACE_RGB);
$i->profileimage('icc', file_get_contents('AdobeRGB1998.icc'));
$i->writeimage($d);
$i->destroy();
?>

Does anyone know how to successfully set the image to RGB and attach the profile?

I did try the different methods and combinations for ‘setImageProfile’ and ‘profileImage’, also for colorspace and imagetype, but the result is always the same.

  • 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-09T05:07:19+00:00Added an answer on June 9, 2026 at 5:07 am

    This worked for me to have it recognized as a truecolor image. Assuming $img is the Imagick object containing the greyscaled image, I check if it is indeed greyscale and then edit 1 random pixel and modify its red value by adding or substracting 5 values, depending on red being greater than 5 or not.

    <?php
    if ($img->getImageType() == Imagick::IMGTYPE_GRAYSCALE)
    {
        // Get the image dimensions
        $dim = $img->getimagegeometry();
    
        // Pick a random pixel
        $x = rand(0, $dim['width']-1);
        $y = rand(0, $dim['height']-1);
    
        // Define our marge
        $marge = 5;
        //$x = 0;
        //$y = 0;
    
        // Debug info
        echo "\r\nTransform greyscale to true color\r\n";
        echo "Pixel [$x,$y]\n";
    
        // Get the pixel from the image and get its color value
        $pixel = $img->getimagepixelcolor($x, $x);
        $color = $pixel->getcolor();
        array_pop($color); // remove alpha value
    
        // Determine old color for debug
        $oldColor   = 'rgb(' . implode(',',$color) . ')';
        // Set new red value
        $color['r'] = $color['r'] >= $marge ? $color['r']-$marge : $color['r'] + $marge;
        // Build new color string
        $newColor   = 'rgb(' . implode(',',$color) . ')';
    
        // Set the pixel's new color value
        $pixel->setcolor($newColor);
    
        echo "$oldColor -> $newColor\r\n\r\n";
    
        // Draw the pixel on the image using an ImagickDraw object on the given coordinates
        $draw = new ImagickDraw();
        $draw->setfillcolor($pixel);
        $draw->point($x, $y);
        $img->drawimage($draw);
    
        // Done, 
        unset($draw, $pixel);
    }
    // Do other stuff with $img here
    ?>
    

    Hope this helps anyone in the future.

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

Sidebar

Related Questions

Where can I find the CorFlags.exe tool ? I made full search of my
Does anybody know of a reliable, well-made tool for creating standalone desktop applications complete
I recently made a c# printer management tool that uses a WCF service which
I've made a basic HTML5/JS comic creation tool that uses the canvas element. I
Background info : I was handed a Tool, which was made using MS-Access 2007,
I made an iphone app to capture image from camera and to set that
Are there ways to get a 3D model (maybe made by a tool like
I'm making Google App Engine project with SpringSource Tool Suite. I made project without
I've made a small tool that parses a chunk of text, does some simple
We're using a small self-made windows-based tool to write OS, Images and a FAT

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.