[SOLVED] CopyPixels() isn't copying. [Missing something BA-SIC]
Posted: 2019-09-23T12:06:59-07:00
In this example, I am trying to copy the top half/bottom half of two different images into a third, but in fact neither of the CopyPixels() registers (the 4th Write is identical to the 3rd). I'm sure I'm missing something basic because even SetPixel() doesn't work. (Like a "commit" step?)
Can you say what might be missing? Thank you.
Can you say what might be missing? Thank you.
Code: Select all
#!/usr/bin/perl
use strict;
use Image::Magick;
my $imageblue = Image::Magick->new;
$imageblue->Set('size'=>'50x50');
$imageblue->ReadImage('xc:blue');
$imageblue->Write('win:'); #or 'show:'
$imageblue->Write('SourceBLUE.png');
my $imagered = Image::Magick->new;
$imagered->Set('size'=>'50x50');
$imagered->ReadImage('xc:red');
$imagered->Write('win:'); #or 'show:'
$imagered->Write('SourceRED.png');
my $imagewhite = Image::Magick->new;
$imagewhite->Set('size'=>'50x50');
$imagewhite->ReadImage('xc:white');
$imagewhite->Write('win:'); #or 'show:'
$imagewhite->Write('TargetWHITE.png');
# read red top paste white top
$imagewhite->CopyPixels($imagered,geometry=>'50x25+0+0',dx=>0,dy=>0); # SYNTAX: missing 'image=>' before $imagered
# read blue top paste white bottom
$imagewhite->CopyPixels($imageblue,geometry=>'50x25+0+0',dx=>0,dy=>25); # Ditto
$imagewhite->Write('win:'); #or 'show:'
$imagewhite->Write('TargetREDBLUE.png');