Hello World ImageMagick Draw Command
Output from helloworld.cgi using imagemagick to read an image called "map.gif" and draw rectangles and circles on top of the map image. Finally outputs the image to a browser with the proper content-type for a gif file. Download the Map here.

Perl Source Code:
#!/usr/bin/perl
binmode STDOUT;
print "Content-type: image/gif\n\n";
use Image::Magick;
my(, );
= Image::Magick->new;
->Read("map.gif");
->Draw(primitive=>'FillRectangle',points=>"10,10 60,80",pen=>'#FFFF00');
->Draw(primitive=>'Rectangle',points=>"10,10 190,190",pen=>"blue",linewidth=>2);
->Draw(primitive=>'Rectangle',points=>"44,44 122,122",pen=>"blue",linewidth=>1);
->Draw(primitive=>'Circle',points=>"50,50 45,32",pen=>"green",linewidth=>5);
->Draw(primitive=>'Rectangle',points=>"14,14 187,187",pen=>"white",linewidth=>2);
->Draw(primitive=>'Rectangle',points=>"26,24 187,187",pen=>'#AAAA00',linewidth=>4);
->Draw(primitive=>'FillRectangle',points=>"110,112 135,136",pen=>"white",linewidth=>1);
->Write('gif:-');
undef ;
And here's another simple ImageMagick script which resizes an image nnn.jpg. This is written in Perl and runs on our server.
#!/usr/bin/perl
use Image::Magick;
my(, );
= Image::Magick->new;
print "Content-type: image/jpeg\n\n";
binmode STDOUT;
->Read("nnn.jpg");
->Scale("50x50");
->Write('jpg:-');
undef ;
exit;
Here's the code working.
|
|