Erich Strelow > Image-Magick-NFPADiamond-1.00 > Image::Magick::NFPADiamond

Download:
Image-Magick-NFPADiamond-1.00.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.00   Source  

Name ^

Image::Magick::NFPADiamond - This module renders a NFPA diamond using ImageMagick

Synopsis ^

   use Image::Magick::NFPADiamond;

   my $diamond=Image::Magick::NFPADiamond->new(red=>3, blue=>0, yellow=>1);
   $diamond->save('warning.jpg');

Description ^

This module composes a NFPA diamond or fire diamond image using ImageMagick perl module.

Methods ^

Image::Magick::NFPADiamond::new()

The constructor takes a series of arguments in a hash notation style, none of wich are mandatory:

red
blue
yellow

The values to appear inside the red, yellow and blud diamonds. Should be a number, but any string would do.

white

The text to appear inside the white diamond. Any string would do. A -W- has a special meaning and produces a strikethrough W to signal a hazardous material that shouln't be mixed with water. JackDaniels is a synonim for this.

size

The size of the resulting image expressed as a single integer. The resulting image is always a square of size x size. If this argument is missing, a size of 320 is assumed.

save([file])

The save() method writes the image to a specified argument. The argument may be a filename, but anything acceptable by ImageMagick should work.

response([format])

The response method() writes the image to STDOUT. This is usefull for a CGI implementation (see the sample below). The argument is a ImageMagick format argument (like 'jpg','gif','png', etc).

handle()

Returns the underlying Magick image so it can be used as an element to another one

Restrictions ^

The diamond generation is done according to the following diagram:

All 4 text are scaled the same, based on the 'AAAA' string on 24px as a seed. This should cover strings like 'ALK', 'ACID'. A longer text will overlap.

The red and blue regions are colored using the ImageMagick provided 'red' and 'yellow' colors. The blue region is '#0063FF' to get a lighter tone.

Sample ^

This script works both with PerlEx and Apache

        #!perl

        #This Perl script will produce a dynamic NFPA alike diamond
        use strict "vars";
        use strict "subs";

        use CGI;
        use Image::Magick::NFPADiamond;

        my $request=new CGI;

    #Using $request->Vars allows for a query_string like 'red=1&blue=2' to work
        my $img=Image::Magick::NFPADiamond->new($request->Vars) || die "Fail\n";

        print $request->header(-type=> "image/jpeg",  -expires=>'+3d');
        binmode STDOUT;
    $img->response('jpg');

See Also ^

http://www.imagemagick.org/script/perl-magick.php, the PerlMagick man page.

AUTHOR ^

Erich Strelow <estrelow@ceresita.cl>

COPYRIGHT AND LICENSE ^

Copyright (C) 2008 by Erich Strelow

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

Disclaimer ^

This module is provided "as is". This is in no way a sanctioned nor official nor verified version of the NFPA standard.

syntax highlighting: