Page 1 of 1

Attribute <image> fails type constraint

Posted: 2014-11-06T18:55:12-07:00
by marc557
I am getting his error when I used Graphics::DZI which must also use Image::Magick

Attribute <image> does not pass the type constraint because: Validation failed for 'Image::Magick' with value record-image.jpg <not isa Image::Magick> at ...

What am I doing wrong?

Thanks,

Marc

This is my code

Code: Select all

use Graphics::DZI;
use strict;
use warnings;

my $image = "record-image.jpg";
my $overlap = "0";
my $tilesize = "256";
my $format = "jpeg";

my $dzi = Graphics::DZI->new(overlap  => $overlap,
                             image    => $image,
                             tilesize => $tilesize
                               );

write_file ("xxx.xml", $dzi->descriptor);
$dzi->iterate ();
exit;

Re: Attribute <image> fails type constraint

Posted: 2014-11-06T19:38:06-07:00
by snibgo
From the documentation http://search.cpan.org/dist/Graphics-DZ ... ics/DZI.pm the image parameter needs to be an Image::Magick object, not a string.

Re: Attribute <image> fails type constraint

Posted: 2014-11-06T21:57:28-07:00
by marc557
But that's the name of the image. How do I specify an image without a name?

Thanks,

Marc

Re: Attribute <image> fails type constraint

Posted: 2014-11-07T01:11:11-07:00
by snibgo
In computer languages, objects have types. For example: string, integer, floating-point, image. I suggest you read a programming tutorial.

Re: Attribute <image> fails type constraint

Posted: 2014-11-07T06:36:24-07:00
by marc557
Snibdgo,

I realize that it is related to the data type. How do I specify an image type in this case?

Thanks,

Marc

Re: Attribute <image> fails type constraint

Posted: 2014-11-07T07:02:06-07:00
by marc557
I modified my code as show in red as it still fails. Can somebody help me? Thanks, Marc

use strict;
use warnings;
use Graphics::DZI;
use Image::Magick;

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


#my $image = "record-image.jpg";
my $overlap = "0";
my $tilesize = "256";
my $format = "jpg";

my $dzi = Graphics::DZI->new(image => $x,
overlap => $overlap,
tilesize => $tilesize,
);

#write_file ("xxx.xml", $dzi->descriptor);
$dzi->iterate ();
# !!! this does only display the tiles on the screen
# !!! see Graphics::DZI::Files for a subclass which
# !!! actually writes to files

Re: Attribute <image> fails type constraint

Posted: 2014-11-07T09:16:17-07:00
by snibgo
Sorry, I don't know Perl and I've never heard of DZI. But the documentation http://www.imagemagick.org/script/perl-magick.php#read tells me that Read() returns the number of images read. $x becomes a number, not an image. Passing a number instead of an image to Graphics::DZI->new() won't work.

There are plenty of examples in this forum that will, I think, work for you.