Combining RGB Channel Images ? How ?

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
QooooQ

Combining RGB Channel Images ? How ?

Post by QooooQ »

Tried the following with several different channel constants.
Result is always a super bright blue colored image... ? why ?
With MagickWand it works, so I thought it should work in a similar way with Imagick too

Imagick

Code: Select all

<?php
$red = new Imagick("separate_red.gif");
$green = new Imagick("separate_green.gif");
$blue = new Imagick("separate_blue.gif");

$rgb = new Imagick();

$rgb->addImage($red);
$rgb->addImage($green);
$rgb->addImage($blue);

$combined = $rgb->combineImages(imagick::CHANNEL_ALL);
header("Content-Type: image/gif");
echo $combined;
?>
MagickWand

Code: Select all

<?php
$red = NewMagickWand();
MagickReadImage( $red, 'rose.jpg' );
MagickSeparateImageChannel( $red, MW_RedChannel ); 

$blue = NewMagickWand();
MagickReadImage( $blue, 'rose.jpg' );
MagickSeparateImageChannel( $blue, MW_BlueChannel ); 

$green = NewMagickWand();
MagickReadImage( $green, 'rose.jpg' );
MagickSeparateImageChannel( $green, MW_GreenChannel ); 

$combo = NewMagickWand();
MagickAddImages($combo,$red);
MagickAddImages($combo,$blue);
MagickAddImages($combo,$green);


$result = NewMagickWand();
$result = MagickCombineImages($combo,MW_AllChannels);

MagickSetFormat($result, 'GIF');
header( 'Content-Type: image/gif' );
MagickEchoImageBlob( $result );
?>
Hope someone can help
Last edited by QooooQ on 2008-11-08T20:06:47-07:00, edited 2 times in total.
QooooQ

Re: Combining RGB Channel Images ? How ?

Post by QooooQ »

By the way
For those who haven't noticed yet...

I want to reproduce this

Code: Select all

  convert  separate_red.gif separate_green.gif separate_blue.gif \
           -combine  rose_combined.gif
From this channels-tutorial
Post Reply