Image-Magick-NFPADiamond
view release on metacpan or search on metacpan
Revision history for Perl extension Image::Magick::NFPADiamond.
0.01 Fri Mar 28 09:14:31 2008
- original version; created by h2xs 1.23 with options
-AX --skip-exporter --use-new-tests -n Image::Magick::NFPADiamond
1.00 Mon Mar 31 09:18:00 2008
- Going public
Makefile.PL view on Meta::CPAN
use 5.00;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'Image::Magick::NFPADiamond',
VERSION_FROM => 'lib/Image/Magick/NFPADiamond.pm', # finds $VERSION
PREREQ_PM => {Image::Magick}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/Image/Magick/NFPADiamond.pm', # retrieve abstract from module
AUTHOR => 'Erich Strelow <estrelow@ceresita.cl>') : ()),
);
Image-Magick-NFPADiamond version 0.01
=====================================
Image::Magick::NFPADiamond
This module renders a NFPA diamond using ImageMagick
Sample:
use Image::Magick::NFPADiamond;
my $diamond=Image::Magick::NFPADiamond->new(red=>3, blue=>0, yellow=>1);
$diamond->save('warning.jpg');
CGI Sample based on this URL: diamond.cgi?red=3&yellow=2
use Image::Magick::NFPADiamond;
use CGI;
my $request=new CGI;
my $diamond=Image::Magick::NFPADiamond->new($request->Vars);
$diamond->response();
March 2008
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
DEPENDENCIES
This module requires these other modules and libraries:
Image::Magick
COPYRIGHT AND LICENCE
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.
lib/Image/Magick/NFPADiamond.pm view on Meta::CPAN
package Image::Magick::NFPADiamond;
use 5.00;
use strict "vars";
use strict "subs";
use Image::Magick;
our $VERSION = '1.00';
=head1 Name
Image::Magick::NFPADiamond - This module renders a NFPA diamond using ImageMagick
=head1 Synopsis
use Image::Magick::NFPADiamond;
my $diamond=Image::Magick::NFPADiamond->new(red=>3, blue=>0, yellow=>1);
$diamond->save('warning.jpg');
=head1 Description
This module composes a NFPA diamond or I<fire diamond> image using ImageMagick perl module.
=head1 Methods
=head2 Image::Magick::NFPADiamond::new()
The constructor takes a series of arguments in a hash notation style, none of wich are mandatory:
=over
=item red
=item blue
lib/Image/Magick/NFPADiamond.pm view on Meta::CPAN
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');
=head1 See Also
L<http://www.imagemagick.org/script/perl-magick.php>, the PerlMagick man page.
=head1 AUTHOR
lib/Image/Magick/NFPADiamond.pm view on Meta::CPAN
my %params=@_;
my $size;
if (exists $params{size}) {
$size=$params{size};
} else {
$size=320; #Default for size
}
my $canvas=Image::Magick->new(size => $size.'x'.$size);
$canvas->Read('xc:white');
my $self={canvas => $canvas, size=>$size};
bless ($self,$class);
$self->_doit();
#Using "AAAA" as the seed to get the text metrics
my @metrics = $canvas->QueryFontMetrics(family=>'Arial', text => "AAAA", stroke=> 'black', align=>'Center', pointsize=>24);
my $scale=($size/4/$metrics[4]).','.($size/4/$metrics[1]);
t/Image-Magick-NFPADiamond.t view on Meta::CPAN
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Image-Magick-NFPADiamond.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use File::Temp qw/ tmpnam /;;
use Test::More tests => 6;
BEGIN { use_ok('Image::Magick::NFPADiamond') };
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
use Image::Magick::NFPADiamond;
my $img1=Image::Magick::NFPADiamond->new();
ok( defined $img1, "Blank constructor");
isa_ok($img1->handle(), "Image::Magick", "Handle method");
my $img=Image::Magick::NFPADiamond->new(red=>1, blue=>2, yellow=>3);
ok( defined $img, "Sample diamond");
open ( my $saveout,'>&', *STDOUT) or die $!;
$tmp=tmpnam().'.jpg';
ok(! $img->save($tmp), "Save method");
@stats=stat($tmp);
( run in 0.347 second using v1.01-cache-2.11-cpan-beeb90c9504 )