version string

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

version string

Post by rmabry »

I see that I can get the version string like so:

Code: Select all

$image = new Image::Magick;
print($image->Get('version'));
But the 'version' attribute doesn't appear in the doc file,

http://www.imagemagick.org/script/perl- ... -attribute

Am I on shaky ground using this "undocumented" feature?

Rick
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

The version attribute does appear in the PerlMagick documentation. Look carefully. Its there.
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Post by rmabry »

magick wrote: The version attribute does appear in the PerlMagick documentation. Look carefully. Its there.


Good grief, I'm going blind. My wife warned me that too much computing would cause this, but did I listen?

Sorry 'bout that.

Rick
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Post by rmabry »

rmabry wrote: Sorry 'bout that.


:oops:

But since we're gathered here on this fine Second Day of Christmas, is there a safe way of telling sub-builds apart, say 6.3.1.4 from earlier ones built on the same day, such as 6.3.1.3 (the final digit not being found in the version string)?

Or barring that, suppose my need for doing so is to detect an option for Draw --- call it 'newopt' --- that appeared at some point. What is an elegant way to test for it, other than trying to use it? I can manage this with some overhead by attempting to apply it to a tiny bogus image, but is there another way? The following seems ugly.

Code: Select all

use Image::Magick;
$image = new Image::Magick;
$image->Set(size=>'1x1');
$image->Read('xc:white');
$uhoh = $image->Draw(primitive => 'point', points => '0,0', newopt=>'whatever');
if($uhoh) { do something else... } 
Rick
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

There is currently no way to return the sub-release number. In your case you could try
  • $x = $image->Get('origin');
and if see if it returns an error.
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Post by rmabry »

magick wrote: In your case you could try
  • $x = $image->Get('origin');
and if see if it returns an error.


How did you know I was trying to use 'origin'?? You really are a wizard, just like your picture.

But seriously, in my case, both of the following return the same thing, namely a blank string. So trying to Get an unknown attribute gives no error?

Code: Select all

$ok = $image->Get('origin');

($ok) ? print("$ok\n") : print("Get(origin) ok\n");

$ok = $image->Get('origami');

($ok) ? print("$ok\n") : print("Get(origami) ok\n");
I presume that 'origin' will soon be a Get-able attribute, but even so, this solution won't quite work for me, since anything pre-origin will also be pre-Get-unknown-attribute-returns-error.

My ugly solution works, though, so I'll use that for now.

Thanks,

Rick
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Doh! Forgot GetAttribute() cannot return exceptions. This works which I think you suggested anyway:

Code: Select all

use Image::Magick;

$image=Image::Magick->new();
$image->Read('logo:');
$x = $image->Draw(origin=>"+0+0");
warn "$x" if "$x";

$x = $image->Draw(orgami=>"+0+0");
warn "$x" if "$x";
In the mean-time 6.3.2 will be released in a few weeks and you could check for version at 6.3.2 or above which guarentees origin is a valid attribute and a parameter of Draw().
Post Reply