Page 1 of 1

[SOLVED] CopyPixels() isn't copying. [Missing something BA-SIC]

Posted: 2019-09-23T12:06:59-07:00
by E. Fudd Wabbitwy
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.

Code: Select all

use strict;
use Image::Magick;

my $imageblue = Image::Magick->new;
$imageblue->Write('win:'); #or 'show:'

my $imagered = Image::Magick->new;
$imagered->Write('win:'); #or 'show:'

my $imagewhite = Image::Magick->new;
$imagewhite->Write('win:'); #or 'show:'

# 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:'

Re: CopyPixels() isn't copying. [Missing something BA-SIC]

Posted: 2019-09-23T19:27:21-07:00
by E. Fudd Wabbitwy
The BA-SIC missing piece, found by more trial-and-error, was the parameter name '$image=>' before the image name:

Code: Select all