[Solved] Composite fail: 410: reference is not my type `Imag

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
tampadavid
Posts: 13
Joined: 2014-06-02T13:11:51-07:00
Authentication code: 6789

[Solved] Composite fail: 410: reference is not my type `Imag

Post by tampadavid » 2014-06-12T07:50:20-07:00

I've looked and head banged this extensively, so now I'm asking for help. Seems that I cannot predict, thus cannot rely on, which parts of the documentation are going to work as advertised. So far, for me and my efforts, Label does not work, and now Composite does not work. This post relates to Composite.

Here's the test script:

Code: Select all

#!/usr/bin/env perl

# perl-jsiiw-Composite.pl: trying to get im's Composite method to work.

use strict;
use warnings;
use Image::Magick;


my ($doll, $t, $coal, $w);

# These are 300x300px pngs from gimp.  the black-dot is transparent, except 
# for the dot.  Ideally, this puts the dot on the white destination png.
$doll = "./white-box-300x300.png";
$t = "./black-dot-300x300.png";

$coal = Image::Magick->new;

$w = $coal->Read("$doll");
warn $w if $w;
$w = $coal->Composite(image=>"$t", compose=>'over', geometry=>"+4+4", gravity=>'center');  # Line 20.
warn $w if $w;
$w = $coal->Write("./blackdot.png");
warn $w if $w;
And here is the error I get when it is run:
Exception 410: reference is not my type `Image::Magick' @ error/Magick.xs/XS_Image__Magick_Mogrify/7505 at /home/david/bin/perl-jsiiw-Composite.pl line 20.
Even when I reduce the method to just reading the image, it fails with that message. Funny though, if I feed it a () it gives:
Exception 410: composite image required `Image::Magick' @ error/Magick.xs/XS_Image__Magick_Mogrify/8279 at /home/david/bin/perl-jsiiw-Composite.pl line 23.
so at least this indicates that the $coal->Composite() method does exist, or else it would not be there to complain. (?)

The test files are a 300x300 white box, and a 300x300 transparent box with a black spot in the middle. I am trying to put the spot on the white background. What I get instead is this error message. This is not the only time Composite has failed. I have been trying to incorporate it into a production script, but cannot, because it does not work at all, according to my attempts based on available documentation.

I've looked for good books on ImageMagick, and there are not any "good" books. I think this is because even those who attempt to write such a book find the project itself too un-documented, or worse, incorrectly documented, to research and report useful reliable information. The point I am making, at least to myself, is that I am not alone in this frustration. That and that I have really tried to find out why Composite is failing.

Your help is needed and appreciated.


David
Last edited by tampadavid on 2014-06-12T19:37:53-07:00, edited 1 time in total.

snibgo
Posts: 12024
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Composite fail: 410: reference is not my type `Image::Ma

Post by snibgo » 2014-06-12T08:01:31-07:00

The documentation http://www.imagemagick.org/script/perl-magick.php says: image=>image-handle. See also examples on this forum, eg viewtopic.php?f=7&t=22255&p=92146.
snibgo's IM pages: im.snibgo.com

tampadavid
Posts: 13
Joined: 2014-06-02T13:11:51-07:00
Authentication code: 6789

Re: Composite fail: 410: reference is not my type `Image::Ma

Post by tampadavid » 2014-06-12T08:46:02-07:00

That's just it. I do not think there is anything wrong with the statement:

Code: Select all

$w = $coal->Composite(image=>"$t", compose=>'over', geometry=>"+4+4", gravity=>'center');
or

Code: Select all

$w = $coal->Composite(image=>$t, compose=>'over', geometry=>"+4+4", gravity=>'center');
and I did not include the documentation in the post, only mentioned it.

I believe something is broken, but I do not know enough to really say. Also, I'd expect more traffic here if something were broken. Or this product is not used nearly as often as I thought.

It still fails. Can anyone see anything wrong with this statement(s)? Can anyone point me to working examples? I have not found any that differ from what I've done here.


David

snibgo
Posts: 12024
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Composite fail: 410: reference is not my type `Image::Ma

Post by snibgo » 2014-06-12T09:33:03-07:00

Correct me if I'm wrong, because I don't do perl, but your $t is a string, "./black-dot-300x300.png".

But "image=>" needs an image handle, not a string. This image handle needs to have been "read" before you use it in Composite. See the example in the thread I linked.
snibgo's IM pages: im.snibgo.com

tampadavid
Posts: 13
Joined: 2014-06-02T13:11:51-07:00
Authentication code: 6789

Re: Composite fail: 410: reference is not my type `Image::Ma

Post by tampadavid » 2014-06-12T19:36:20-07:00

Whow! RTFP.

You are correct, sir. I now realize that there is no particular "ImageMagick", there is instead, a confederation of programs that combine to form this distribution of graphics utilities called "ImageMagick". I say that because building gif animations takes filenames, not image handles. Hats off and thank you. I would not have gotten this without your help.

Here's the working example:

Code: Select all

#!/usr/bin/env perl

# perl-jsiiw-Composite.pl: trying to get im's Composite method to work.

use strict;
use warnings;
use Image::Magick;


my ($doll, $t, $coal, $sharona, $w);

# These are 300x300px pngs from gimp.  the black-dot is transparent, except 
# for the dot.  Ideally, this puts the dot on the white destination png.
$doll = "./white-box-300x300.png";
$t = "./black-dot-300x300.png";

$sharona = Image::Magick->new;
$w = $sharona->Read($t);
warn $w if $w;
$coal = Image::Magick->new;
$w = $coal->Read("$doll");
warn $w if $w;
#$w = $coal->Composite(image=>$t);
$w = $coal->Composite(image=>$sharona, compose=>'over', geometry=>"+4+4", gravity=>'center');
warn $w if $w;
$w = $coal->Write("./blackdot.png");
warn $w if $w;
With the particular lesson being the need to record the overlay image in an image object, rather than being read from a file. Also, trying to extrapolate from examples using the bash versions does not indicate this step.

Thank you again snibgo. Marking [solved]


David

Post Reply