Good documentation or good source examples for Image::Magick or converterfrom commandline to perl

Discussion in 'Perl Misc' started by nntpman68, Apr 1, 2008.

  1. nntpman68

    nntpman68 Guest

    Hi,

    Normally CPAN documentation is quite good.

    However I'm having some problems with ImageMagick.

    Could anybody point me to some good concise documentation.

    Reading the Imagemagick documentation and guestimating how to pass the
    same parameters to the perl equivalemt is not always simple:

    Example:

    Assume following ImageMagic command:

    convert -size 64x64 xc:transparent -pointsize 10 -draw "text 0,20
    'hello'" test.png


    I'd like to do the same in perl:

    my $g = Image::Magick->new;
    $g->Set(size=>"64x64");
    $g->ReadImage('xc:transparent');
    $g->Draw( primitive => 'text', BUT_WHAT_IS_THE_SYNTAX_HERE_???? );
    $g->Write("test.png");

    and don't really know where to look.


    Any hint / document is welcome


    bye

    N
    nntpman68, Apr 1, 2008
    #1
    1. Advertising

  2. nntpman68

    nntpman68 Guest

    Re: Good documentation or good source examples for Image::Magickor converter from commandline to perl

    Hi,

    I'm still not succeeding with drawing a text :-( .


    Following attempt doesn't produce any text, put doesn't print any error
    / warning:

    my %textopts = (
    primitive => 'text' ,
    stroke => 'red' ,
    pointsize => 12 ,
    points => "20,20"
    );

    $err = $g->Draw( %textopts );
    warn "$err" if "$err";


    whereas following command (with same %textopts as above)

    $err = $tile->Draw( %textopts );
    warn "$err" if "$err";

    Produces the message:
    Exception 410: unrecognized option `text' at ./test.pl line 103.

    The only doc, that I found:
    http://www.imagemagick.org/script/perl-magick.php

    seems to indicate, that the option is 'text'

    > Draw primitive=>{point, line, rectangle, arc, ellipse, circle, path, polyline, polygon, bezier, color, matte, text, @filename}, points=>string , method=>{Point, Replace, Floodfill, FillToBorder, Reset}, stroke=>color name, fill=>color name, font=>string, pointsize=>integer, strokewidth=>float, antialias=>{true, false}, bordercolor=>color name, x=>float, y=>float, dash-offset=>float, dash-pattern=>array of float values, affine=>array of float values, translate=>float, float, scale=>float, float, rotate=>float, skewX=>float, skewY=>float, interpolate=>{undefined, average, bicubic, bilinear, mesh, nearest-neighbor, spline}, text=>string, vector-graphics=>string annotate an image with one or more graphic primitive


    What am I overlooking?


    bye


    N

    nntpman68 wrote:
    > Hi,
    >
    > Normally CPAN documentation is quite good.
    >
    > However I'm having some problems with ImageMagick.
    >
    > Could anybody point me to some good concise documentation.
    >
    > Reading the Imagemagick documentation and guestimating how to pass the
    > same parameters to the perl equivalemt is not always simple:
    >
    > Example:
    >
    > Assume following ImageMagic command:
    >
    > convert -size 64x64 xc:transparent -pointsize 10 -draw "text 0,20
    > 'hello'" test.png
    >
    >
    > I'd like to do the same in perl:
    >
    > my $g = Image::Magick->new;
    > $g->Set(size=>"64x64");
    > $g->ReadImage('xc:transparent');
    > $g->Draw( primitive => 'text', BUT_WHAT_IS_THE_SYNTAX_HERE_???? );
    > $g->Write("test.png");
    >
    > and don't really know where to look.
    >
    >
    > Any hint / document is welcome
    >
    >
    > bye
    >
    > N
    >
    >
    nntpman68, Apr 1, 2008
    #2
    1. Advertising

  3. nntpman68

    nntpman68 Guest

    Re: Good documentation or good source examples for Image::Magickor converter from commandline to perl

    Thanks a lot Frank,


    That's also the one, which I found and tried to understand.

    Any perl script displaying a text with the Image::Magick::Draw method
    would solve my current problem.

    Perhaps I manage to google for an example, though I didn't get a useful
    hit so far


    bye

    N


    Frank Seitz wrote:
    > nntpman68 wrote:
    >> I'd like to do the same in perl:
    >>
    >> my $g = Image::Magick->new;
    >> $g->Set(size=>"64x64");
    >> $g->ReadImage('xc:transparent');
    >> $g->Draw( primitive => 'text', BUT_WHAT_IS_THE_SYNTAX_HERE_???? );
    >> $g->Write("test.png");
    >>
    >> and don't really know where to look.
    >>
    >> Any hint / document is welcome

    >
    > I know the problem.
    > http://imagemagick.org/script/perl-magick.php
    > At least you find the possible parameters there.
    >
    > Frank
    nntpman68, Apr 1, 2008
    #3
  4. nntpman68

    John Bokma Guest

    Re: Good documentation or good source examples for Image::Magick or converter from commandline to perl

    nntpman68 <> wrote:

    > Thanks a lot Frank,


    Post top please not do

    > That's also the one, which I found and tried to understand.
    >
    > Any perl script displaying a text with the Image::Magick::Draw method
    > would solve my current problem.


    There is a security image (CAPTCHA) module - GD::SecurityImage - on CPAN
    that can use Image::Magick. I am not sure if that has a good example of
    what you want to achieve though.

    --
    John

    http://johnbokma.com/perl/
    John Bokma, Apr 1, 2008
    #4
  5. nntpman68

    J. Gleixner Guest

    Re: Good documentation or good source examples for Image::Magickor converter from commandline to perl

    nntpman68 wrote:
    > Hi,
    >
    > I'm still not succeeding with drawing a text :-( .
    >
    >
    > Following attempt doesn't produce any text, put doesn't print any error
    > / warning:


    Of course, you didn't provide anything for it to 'Draw'. :)

    >
    > my %textopts = (
    > primitive => 'text' ,
    > stroke => 'red' ,
    > pointsize => 12 ,
    > points => "20,20"
    > );
    >
    > $err = $g->Draw( %textopts );
    > warn "$err" if "$err";
    >
    >
    > whereas following command (with same %textopts as above)
    >
    > $err = $tile->Draw( %textopts );
    > warn "$err" if "$err";
    >
    > Produces the message:
    > Exception 410: unrecognized option `text' at ./test.pl line 103.


    I guess $tile and $g aren't the same class.

    Try either of these:

    $obj->Annotate(
    x => 0,
    y => 20,
    text => 'Blah' );

    $obj->Draw(
    primitive => 'Text',
    points => '0,20 "Blah"' );

    Graphics Programming with Perl
    http://www.manning.com/verbruggen/
    J. Gleixner, Apr 2, 2008
    #5
  6. nntpman68

    nntpman68 Guest

    Re: Good documentation or good source examples for Image::Magickor converter from commandline to perl

    Thanks a lot.

    This was just a typo. however it also didn't work when I used $g on both
    places.


    bye

    N
    J. Gleixner wrote:
    > nntpman68 wrote:
    >> Hi,
    >>
    >> I'm still not succeeding with drawing a text :-( .
    >>
    >>
    >> Following attempt doesn't produce any text, put doesn't print any
    >> error / warning:

    >
    > Of course, you didn't provide anything for it to 'Draw'. :)
    >
    >>
    >> my %textopts = (
    >> primitive => 'text' ,
    >> stroke => 'red' ,
    >> pointsize => 12 ,
    >> points => "20,20"
    >> );
    >>
    >> $err = $g->Draw( %textopts );
    >> warn "$err" if "$err";
    >>
    >>
    >> whereas following command (with same %textopts as above)
    >>
    >> $err = $tile->Draw( %textopts );
    >> warn "$err" if "$err";
    >>
    >> Produces the message:
    >> Exception 410: unrecognized option `text' at ./test.pl line 103.

    >
    > I guess $tile and $g aren't the same class.
    >
    > Try either of these:
    >
    > $obj->Annotate(
    > x => 0,
    > y => 20,
    > text => 'Blah' );
    >
    > $obj->Draw(
    > primitive => 'Text',
    > points => '0,20 "Blah"' );
    >
    > Graphics Programming with Perl
    > http://www.manning.com/verbruggen/
    nntpman68, Apr 2, 2008
    #6
  7. nntpman68

    nntpman68 Guest

    Re: Good documentation or good source examples for Image::Magickor converter from commandline to perl

    Hi J,


    I tried both of your examples.
    With my version of Image::Magick both work.


    Excellent. Thanks a lot :)

    Looking at David Harmon's reply it seems better to stick with annotate.
    I'll do so.


    bye


    N


    J. Gleixner wrote:
    > nntpman68 wrote:
    >> Hi,
    >>
    >> I'm still not succeeding with drawing a text :-( .
    >>
    >>
    >> Following attempt doesn't produce any text, put doesn't print any
    >> error / warning:

    >
    > Of course, you didn't provide anything for it to 'Draw'. :)
    >
    >>
    >> my %textopts = (
    >> primitive => 'text' ,
    >> stroke => 'red' ,
    >> pointsize => 12 ,
    >> points => "20,20"
    >> );
    >>
    >> $err = $g->Draw( %textopts );
    >> warn "$err" if "$err";
    >>
    >>
    >> whereas following command (with same %textopts as above)
    >>
    >> $err = $tile->Draw( %textopts );
    >> warn "$err" if "$err";
    >>
    >> Produces the message:
    >> Exception 410: unrecognized option `text' at ./test.pl line 103.

    >
    > I guess $tile and $g aren't the same class.
    >
    > Try either of these:
    >
    > $obj->Annotate(
    > x => 0,
    > y => 20,
    > text => 'Blah' );
    >
    > $obj->Draw(
    > primitive => 'Text',
    > points => '0,20 "Blah"' );
    >
    > Graphics Programming with Perl
    > http://www.manning.com/verbruggen/
    nntpman68, Apr 2, 2008
    #7
  8. nntpman68

    Guest

    , Apr 2, 2008
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric McDaniel

    Image::Magick and Tk::Photo

    Eric McDaniel, Aug 30, 2003, in forum: Perl
    Replies:
    2
    Views:
    1,583
    Joseph Brenner
    Sep 20, 2003
  2. Rob Bell
    Replies:
    4
    Views:
    207
    Martien Verbruggen
    Sep 10, 2003
  3. Replies:
    9
    Views:
    320
  4. Replies:
    2
    Views:
    512
    Paul Lalli
    Feb 6, 2006
  5. Jack
    Replies:
    2
    Views:
    204
    John W. Krahn
    Jan 25, 2008
Loading...

Share This Page