Page 1 of 1

Combining RGB Channel Images ? How ?

Posted: 2008-11-08T19:33:46-07:00
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

Re: Combining RGB Channel Images ? How ?

Posted: 2008-11-08T19:37:46-07:00
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