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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:50:02+00:00 2026-06-05T07:50:02+00:00

So I have a situtation with ImageMagick and php where I need to processes

  • 0

So I have a situtation with ImageMagick and php where I need to processes each of the RGB channels separately and then merge them back together into the final image. So in the code I have below, $red, $green and $blue are the channels (as gray scale images). The following code is what I have tried (and a couple variations) but each time I end up with an image that only has Cyan, Magenta or Yellow showing through. In this case, the resulting image is Cyan.

$im->removeImage();
$im->addImage($red);
$im->addImage($green);
$im->addImage($blue);
$img = $im->combineImages(self::CHANNEL_ALL);

$im->removeImage();
$im->removeImage();
$im->removeImage();
$im->addImage($img);

I think part of my problem is that the PHP documentation doesn’t say much about how to use combineImages and there are no samples so far as I can find. So it’s very likely that I’m using that particular method incorrectly, and I suspect it has to do with how I am combining the images in the single Imagick object to begin with.

EDIT

This question ultimately boils down to this: How do I recreate the following script using only php?

convert tmp_r.png tmp_g.png tmp_b.png -combine tmp_rgb.png
  • 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-05T07:50:03+00:00Added an answer on June 5, 2026 at 7:50 am

    So I think I’ve figured out how to get this to work. The missing piece was a call to flattenImages(). I’m not exactly sure why this worked, but it seems to be what I was looking for. Here’s the code (keep in mind that $this is in the context of a member method of a class that extends Imagick):

    $this->removeImage(); // gets rid of the old, unprocessed image
    $rgb = clone $this;
    
    $rgb->addImage($red);
    $rgb->addImage($green);
    $rgb->addImage($blue);
    $rgb->flattenImages(); // this is what was missing above
    
    $rgb = $rgb->combineImages(self::CHANNEL_ALL);
    
    $this->addImage($rgb);
    

    Can anyone comment on why this might be? I expected flattenImages() to merge the three images into one and destroy some of the information, but it appears that it actually tells ImageMagick to process all of the contained images together whereas it was processing them independently previously.

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

Sidebar

Related Questions

I have situation where I need to change the order of the columns/adding new
i've got a situtation where we have a web site (mvc project), and a
I have situation where I need to make sure that user has completed certain
I have situation in which i'm compelled to retrieve 30,000 records each to 2
Here's my situtation. I have a Repeater bound to a List, which is rendering
I have a php page where I add and delete items from database using
I have a PHP function below that is used for a command line tool
Situation: Have a UITextField instance which is a subview of a UIScrollView. Need: Screen
I have a situation where I need to have a user select a region
I have searched StackOverflow and cannot find a situtation like mine. I am using

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.