problem running composite - exception 410 [solved]

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
symulant
Posts: 2
Joined: 2011-06-26T08:55:28-07:00
Authentication code: 8675308

problem running composite - exception 410 [solved]

Post by symulant » 2011-06-26T11:53:34-07:00

I want to move the code from bash to Perl

Code: Select all

#!/bin/bash
composite -compose plus image.png mask.png image_mask0.png
Bash script works fine.

I tried three times to write it using Perl and the Image:: Magick:

Code: Select all

#!/usr/bin/perl -w
use strict;
use Image::Magick;

my $im_x;
$im_x=Image::Magick->new;

my $x=$im_x->Composite(compose=>"Plus", image=>"image.png", mask=>"mask.png");
warn "$x" if "$x";

$im_x->Write("image_mask1.png");

undef $im_x;

Code: Select all

#!/usr/bin/perl -w
use strict;                                                                                                                                         
use Image::Magick;                                                                                                                                  
                                                                                                                                                    
my $im_x;                                                                                                                                           
$im_x=Image::Magick->new;                                                                                                                           

my $x=$im_x->Composite(compose=>'Plus', image=>'image.png', mask=>'mask.png');
warn "$x" if "$x";

$im_x->Write("image_mask2.png");

undef $im_x;

Code: Select all

#!/usr/bin/perl -w
use strict;
use Image::Magick;

my $image=Image::Magick->new;
$image->Read("image.png");

my $mask =Image::Magick->new;
$mask->Read("mask.png");

my $im_x;
$im_x=Image::Magick->new;

my $x=$im_x->Composite(compose=>'Plus', image=>$image, mask=>$mask);
warn "$x" if "$x";

$im_x->Write("image_mask3.png");
$image->Write("image3.png");
$mask->Write("mask3.png");

undef $im_x;
undef $image;
undef $mask;
The script always ended with a message
Exception 410: no images defined `Composite' @ error/Magick.xs/XS_Image__Magick_Mogrify/7336 at ./compose_test1.pl line 9 (or 15).
and image_mask.png files are not created.

I use perl-PerlMagick 6.6.5.8-7.3, ImageMagick 6.6.5.8-7.3, Perl 5.12.3-11.14.1 on openSUSE 11.4.

What am I doing wrong?
Last edited by symulant on 2011-06-27T09:36:26-07:00, edited 1 time in total.

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: problem running composite - exception 410

Post by anthony » 2011-06-26T18:41:39-07:00

You need to read (or at least create) BOTH images into separate image arrays first!
That is what that error is telling you. One or both images are not present!

Code: Select all

#!/usr/bin/perl
use Image::Magick;
$dest = Image::Magick->new();
$dest->Read('granite:');

$src = Image::Magick->new();
$src->Read('rose:');

$offset="+10+10";

$dest->Composite(image=>$src, compose=>'over', geometry=>$offset);

$dest->write("show:");
Composite() does not create a new image. It only overwrites an existing image. If you want to preserve the original image, clone it first!

See Examples in PerlMagick/demo subdirectory of the sources. (probably loaded in "/usr/share/docs/ImageMagick-perl-*/demo" on your linux machine).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

symulant
Posts: 2
Joined: 2011-06-26T08:55:28-07:00
Authentication code: 8675308

Re: problem running composite - exception 410 [solved]

Post by symulant » 2011-06-27T09:49:48-07:00

Anthony, thank you for your reply.

Post Reply