On Wed, 17 Dec 2008 09:20:36 -0500 (EST) "Jim Shupert, Jr." <[email protected]> wrote:
>my 1st efforts results in so many errors -- oh where to begin -- so i read >that there is PerlMagic > >I am currently reading http://www.imagemagick.org/script/perl-magick.php >and http://www.imagemagick.org/script/examples.php >excellent examples -- i am going to be working through some of that >( i wish there was a convert example that added text ) >Q2 - would a better idea be to have a linux server ( Ubuntu or centOS5 ) >actually DO the PerlMagic image manipulation ( the making of the pdfs ) >meaning - Are the "resources' for learning are more Lnx than win? Perl was designed for linux/unix types of systems, and the linux compilers come pre-installed and easier to use...so you can always compile source code that will work on your particular machine. With win32, you need to get compatible binaries, and compiling your own is mind-boggling. So yes.....it's all easier on Linux. :-) > >Q3 - I would love to know ... what is : >warn "$x" if "$x"; # print the error message >so is "$X" defined defined in the PerlMagic install ? No, that is just an odd peculiarity that you seldom see in Perl. Usually in Perl, you use the syntax $object->do_something() or warn "$!\n"; where the error gets placed into $! but the xs code that hooks Perl into ImageMagick can't do it, and any error is returned from the object method call. my $x; $x = $image->Read('girl.png', 'logo.png', 'rose.png'); warn "$x" if "$x"; So just take it as an oddball thing, that is only seen with PerlMagick, as far as my experience goes. >example -- here is my perl on winXP ( hey - thought you could use a laugh ) > >#C:\perl\bin\perl >use warnings; >use strict; > convert D:\ss\mich-b.jpg ^ >-fill black -pointsize 24 -draw "text 150,460 'File Name : FName7'" ^ >-fill black -pointsize 24 -draw "text 150,490 'Title : TName7'" ^ >-fill black -pointsize 24 -draw "text 150,520 'Creator : Creater7'" ^ >-fill black -pointsize 20 -draw "text 150,550 'Time : hh:mm:ss'" ^ >-fill black -pointsize 18 -draw "text 150,580 'Date : mm/dd/yy'" ^ > D:\ss\mich-b-7.pdf > >exit; There is no convert in PerlMagick. Convert is a c utility that encompasses many of the IM options. In Perl, all those options are separate methods. Like Draw, Annotate, Composite, etc. You could run the shell code thru system in Perl, like: system qq( convert D:\ss\mich-b.jpg -fill black -pointsize 24 -draw "text 150,460 'File Name : FName7'" -fill black -pointsize 24 -draw "text 150,490 'Title : TName7'" -fill black -pointsize 24 -draw "text 150,520 'Creator : Creater7'" -fill black -pointsize 20 -draw "text 150,550 'Time : hh:mm:ss'" -fill black -pointsize 18 -draw "text 150,580 'Date : mm/dd/yy'" D:\ss\mich-b-7.pdf); Perl also has backticks, qx, and exec for running shell code from Perl. But to do your example right, in Perl, it would go something like this: #!/usr/bin/perl use warnings; use strict; use Image::Magick; my $image = Image::Magick->new; $image->Set(size=>'612x792'); # US letter 8.5 x 11 inches my $rc = $image->Read("xc:white"); # or read in your file $image->Annotate( stroke => 'black', pointsize => 24, fill => 'black', text => 'File Name : FName7', x => 150, y => 160, ); $image->Annotate( stroke => 'red', pointsize => 36, fill => 'pink', text => 'Title : TName7', x => 150, y => 260, ); $image->Annotate(text=>'This is a test!', geometry=>'+30+140', fill=>'green', pointsize=>24, rotate=>45.0); $image->Write("$0.pdf"); __END__ There are a couple of things to notice. If you look at the PerlMagick php page, Draw will be listed with 'text' as a primitive. BUT.... you use Annotate to do text in Perl, Draw is for shapes. If you are looking for the right method, grep thru the examples in the PerlMagick subdir. You will see Annotate is used for all text. You might also like this: http://perlmonks.org?node_id=725895 It shows how to watermark with images and text in PerlMagick. Have fun, zentara -- I'm not really a human, but I play one on earth. http://zentara.net/Remember_How_Lucky_You_Are.html _______________________________________________ Magick-users mailing list [email protected] http://studio.imagemagick.org/mailman/listinfo/magick-users
