Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Image::Magick "geometry" argument?

by Tommy (Chaplain)
on Jul 19, 2003 at 23:07 UTC ( [id://275947]=perlquestion: print w/replies, xml ) Need Help??

Tommy has asked for the wisdom of the Perl Monks concerning the following question:

Many of the methods in Image::Magick require an argument named "geometry". The docs at http://www.imagemagick.org/www/perl.html are very vague about this. I don't understand what the "geometry" argument is for, and I don't understand what kind of values to assign it. It requires a syntax that I can't grasp. Can someone enlighten me?

Example taken from the documentation:

$x = $image->Crop(geometry=>'100x100"+100"+100');
A few methods that require the "geometry" argument, as described in the docs:
+-------------------+------------------------------------------------------+
| Method            | Parameters                                           |
+===================+======================================================+
| AdaptiveThreshold | geometry=>geometry, width=>integer, height=>integer, |
|                   | offset=>integer                                      |
+-------------------+------------------------------------------------------+
| Blur              | geometry=>geometry, radius=>double, sigma=>double    |
+-------------------+------------------------------------------------------+
| Border            | geometry=>geometry, width=>integer, height=>integer, |
|                   | fill=>color name                                     |
+-------------------+------------------------------------------------------+
| ColorFloodfill    | geometry=>geometry, x=>integer, y=>integer,          |
|                   | fill=>color name, bordercolor=>color name,           |
|                   | fuzz=>double                                         |
+-------------------+------------------------------------------------------+
| Crop              |geometry=>geometry, width=>integer, height=>integer,  |
|                   |x=>integer, y=>integer                                |
+-------------------+------------------------------------------------------+
| Emboss            | geometry=>geometry, radius=>double, sigma=>double    |
+-------------------+------------------------------------------------------+
Some help please?

--
Tommy Butler, a.k.a. TOMMY

edited: Sun Jul 20 15:11:05 2003 by jeffa - formatting

Replies are listed 'Best First'.
•Re: Image::Magick "geometry" argument?
by merlyn (Sage) on Jul 20, 2003 at 00:15 UTC
      
      Well that's obvious.  NOT!  What an excellent help!  Thank you very much.
      
      --
      Tommy Butler, a.k.a. TOMMY
      
Re: Image::Magick "geometry" argument?
by ctilmes (Vicar) on Jul 19, 2003 at 23:16 UTC
      Thanks for the quick reply.  I'll take a look.  So far at their website
      I've been unable to find anything substantive.  Hope I can find something...
      I'll follow up with what I learn.
      
      --
      Tommy Butler, a.k.a. TOMMY
      
Re: Image::Magick "geometry" argument?
by thpfft (Chaplain) on Jul 20, 2003 at 00:07 UTC

    I remember trying to work this out. It turns out that the geometry parameter is just a string that describes the dimensions of either the finished image or the working area. eg:

    my $ret = $image->Resize( geometry => "100x100" ); die "... $ret" if $ret;

    just tells IM to resize $image to 100 pixels square. The value can be more complicated, as in your Crop example where the offsets are also defined. I imagine the complex string parameters can be blamed on the command-line origins of all these tools.

Re: Image::Magick "geometry" argument?
by Dog and Pony (Priest) on Jul 20, 2003 at 00:48 UTC
    Well it is very nonobvious, because IIRC the module only passes the same raw arguments you would use on the commandline on to ImageMagick. If you want to learn it, try to play around with ImageMagick on the commandline, using the regular docs. Those aren't excellent either, but better.

    I've given up on using Image::Magick a long time ago, because it was so buggy and really didn't offer anything extra - I just wound up using system calls instead. Maybe it has become better or at least more stable now, I don't know.


    You have moved into a dark place.
    It is pitch black. You are likely to be eaten by a grue.
      Do you prefer GD to Image::Magick?
      --
      Tommy Butler, a.k.a. TOMMY
      
        Actually, I like ImageMagick (the tool itself) very much, it is very powerful, and with plugins like GhostScript even more so. I just didn't like the Perl interface. Mind you, it was quite some time ago I tried it last. It might have grown better.

        I haven't used GD much, but I've seen what others do with it, and that is likewise a very good package from what I can see. What one uses is probably mostly a matter of what is appropriate for the task at hand and what one likes. Though I *think* that GD is more for creating images, while ImageMagick is more suited to manipulating existing images. That is, if you want to produce charts, graphs or anything like that, GD is probably much better. If you want to create thumbnails for a huge photoalbum, then ImageMagick sure is a great tool (and here I don't know about GD).


        You have moved into a dark place.
        It is pitch black. You are likely to be eaten by a grue.
Re: Image::Magick "geometry" argument?
by xaptronic (Initiate) on Mar 15, 2012 at 19:36 UTC
    I would like to note since it seems to be impossible to find a verbatim answer to this without being redirected to outdated pages and old docs, that the geometry parameter that is ominously referred to throughout the docs is a string of the following format: WIDTHxHEIGHT+XOFF+YOFF. I found this by looking in man X as specified above.

      [man://X]X

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://275947]
Approved by phydeauxarff
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-03-28 17:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found