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

N

nntpman68

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
 
N

nntpman68

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
 
N

nntpman68

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
 
J

John Bokma

nntpman68 said:
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.
 
J

J. Gleixner

nntpman68 said:
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/
 
N

nntpman68

Thanks a lot.

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


bye

N
 
N

nntpman68

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top