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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:24:33+00:00 2026-06-05T20:24:33+00:00

I am using the Imagick library to work with ImageMagick in PHP. I am

  • 0

I am using the Imagick library to work with ImageMagick in PHP. I am first reading an (JPEG) image from an external server with:

$img = new Imagick();
$img->readImage($source);

And then upload it to my Amazon S3 bucket with the following code:

$s3 = new AmazonS3();
$s3->create_object(BUCKET, $destination_path, array(
    'body' => $img->getImageBlob(),
    'length' => $img->getImageSize(),
    'acl' => AmazonS3::ACL_PUBLIC,
    'contentType' => 'image/jpeg'
));

Everything seems to be working fine, the files appear in my storage bucket and I can view them in my browser. However, when handling greyscale images, ImageMagick converts the image from 24 bit depth to 8 bit depth. I would like them to keep their 24 bit depth, how could I achieve this? I’ve tried the following, without success:

$img->setImageType(imagick::IMGTYPE_TRUECOLOR);

For colorized images, everything works fine, images keep their 24 bit depth.

Edit:

It seems that ImageMagick changes the image type from 6 (truecolor) to 2 (greyscale). Trying to overwrite this does not work, as tested with the following code:

$img = new Imagick();
$img->readImage($source);
$img->setImageType(6);
echo $img->getImageType();

which outputs 2

  • 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-05T20:24:34+00:00Added an answer on June 5, 2026 at 8:24 pm

    Use setType() before you load the image. So:

    $img = new Imagick();
    $img->setType(6); //or use imagick::IMGTYPE_TRUECOLOR instead of 6
    $img->loadImage($source);
    

    This will output an image with truecolor, even if the loaded picture uses graycolors only.

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

Sidebar

Related Questions

I'm using php Imagick library for some image manipulation. I can distort the perspective
We are adding some text using annotateimage function using imagick library in php. Source
I'm importing SVGs with imagick using this syntax $graphic = new Imagick($this->img); The problem
I'm looking to center crop and image using Imagick PHP apis (not command line
I am trying to remove transparent areas of an image with php using imagick.
I'm using php Imagick class for a project I try to composite an image
I'm trying to convert PDF to IMG (JPG) with help PHP. I'm using imagick
I'm converting .jpg and .gif images to .png using PHP's Imagick library. I've successfully
I'm using ImageMagick to convert a RAW file (*.nef extension) into a JPEG image.
I need to annotate an image with Chinese Text and I am using Imagick

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.