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

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 [ Di, 01 April 2008 23:23 ] [ ID #1933316 ]

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

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
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
Frank Seitz [ Mi, 02 April 2008 00:04 ] [ ID #1933317 ]

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

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, [at] 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 [ Mi, 02 April 2008 00:07 ] [ ID #1933318 ]

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

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 [ Mi, 02 April 2008 00:13 ] [ ID #1933319 ]

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

nntpman68 <news1234 [at] free.fr> 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 [ Mi, 02 April 2008 00:54 ] [ ID #1933322 ]

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

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/
glex_no-spam [ Mi, 02 April 2008 02:04 ] [ ID #1934171 ]

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

On Wed, 02 Apr 2008 00:07:15 +0200 in comp.lang.perl.misc, nntpman68
<news1234 [at] free.fr> wrote,
>$err = $tile->Draw( %textopts );
>warn "$err" if "$err";
>
>Produces the message:
>Exception 410: unrecognized option `text' at ./test.pl line 103.

draw "text" is no longer supported in recent versions of
ImageMagick; annotate must be used instead.
David Harmon [ Mi, 02 April 2008 05:30 ] [ ID #1934188 ]

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

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 [ Mi, 02 April 2008 08:39 ] [ ID #1934195 ]

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

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 [ Mi, 02 April 2008 08:43 ] [ ID #1934196 ]

Re: Good documentation or good source examples for Image::Magick or

On Apr 2, 12:13=A0am, nntpman68 <news1... [at] free.fr> wrote:
>
> Perhaps I manage to google for an example, though I didn't get a useful
> hit so far
>

Hope you're using the right search tool in google for code-search,
e.g. like this:

http://www.google.com/codesearch?hl=3Den&q=3D%22use+Image%3A %3AMagick%22+%22=
-%3EAnnotate%22+text%5Cs%2A%3D%3E+lang:perl

Wolfram
w.c.humann [ Mi, 02 April 2008 15:12 ] [ ID #1934213 ]
Perl » comp.lang.perl.misc » Good documentation or good source examples for Image::Magick or converterfrom commandline to perl

Vorheriges Thema: What is best CMS - SilverStripe, Joomla or Drupal
Nächstes Thema: FAQ 8.25 How can I capture STDERR from an external command?