=item *
-Imager - This document - Synopsis Example, Table of Contents and
+Imager - This document - Synopsis, Example, Table of Contents and
Overview.
=item *
This example creates a completely black image of width 400 and height
300 and 4 channels.
-When an operation fails which can be directly associated with an image
-the error message is stored can be retrieved with
-C<$img-E<gt>errstr()>.
+=head1 ERROR HANDLING
-In cases where no image object is associated with an operation
-C<$Imager::ERRSTR> is used to report errors not directly associated
-with an image object. You can also call C<Imager->errstr> to get this
-value.
+In general a method will return false when it fails, if it does use the errstr() method to find out why:
+
+=over
+
+=item errstr
+
+Returns the last error message in that context.
+
+If the last error you received was from calling an object method, such
+as read, call errstr() as an object method to find out why:
+
+ my $image = Imager->new;
+ $image->read(file => 'somefile.gif')
+ or die $image->errstr;
+
+If it was a class method then call errstr() as a class method:
+
+ my @imgs = Imager->read_multi(file => 'somefile.gif')
+ or die Imager->errstr;
+
+Note that in some cases object methods are implemented in terms of
+class methods so a failing object method may set both.
+
+=back
The C<Imager-E<gt>new> method is described in detail in
L<Imager::ImageTypes>.
crop() - L<Imager::Transformations/crop> - extract part of an image
+def_guess_type() - L<Imager::Files/def_guess_type>
+
deltag() - L<Imager::ImageTypes/deltag> - delete image tags
difference() - L<Imager::Filters/"Image Difference">
lib/Imager/Font/Win32.pm
lib/Imager/Font/Wrap.pm
lib/Imager/Fountain.pm
+lib/Imager/Handy.pod
lib/Imager/ImageTypes.pod
lib/Imager/Inline.pod Using Imager with Inline::C
lib/Imager/Matrix2d.pm
# Parse color spec into an a set of 4 colors
-sub pspec {
+sub _pspec {
return (@_,255) if @_ == 3 && !grep /[^\d.+eE-]/, @_;
return (@_ ) if @_ == 4 && !grep /[^\d.+eE-]/, @_;
if ($_[0] =~
sub new {
shift; # get rid of class name.
- my @arg = pspec(@_);
+ my @arg = _pspec(@_);
return @arg ? new_internal($arg[0],$arg[1],$arg[2],$arg[3]) : ();
}
sub set {
my $self = shift;
- my @arg = pspec(@_);
+ my @arg = _pspec(@_);
return @arg ? set_internal($self, $arg[0],$arg[1],$arg[2],$arg[3]) : ();
}
# Parse color spec into an a set of 4 colors
-sub pspec {
+sub _pspec {
return (@_,1) if @_ == 3;
return (@_ ) if @_ == 4;
if ($_[0] =~
return ();
}
-
-
sub new {
shift; # get rid of class name.
- my @arg = pspec(@_);
+ my @arg = _pspec(@_);
return @arg ? new_internal($arg[0],$arg[1],$arg[2],$arg[3]) : ();
}
sub set {
my $self = shift;
- my @arg = pspec(@_);
+ my @arg = _pspec(@_);
return @arg ? set_internal($self, $arg[0],$arg[1],$arg[2],$arg[3]) : ();
}
-
-
-
-
1;
__END__
This table is not included as part of Imager::Color itself since it's
moderately large.
-There is only one method: get($name).
+There is only one method:
+
+=over
+
+=item get
+
+ my @rgb = Imager::Color::Table->get('red')
+ or die "No red found";
+
+Retrieves a color from Imager::Color::Tables built-in color table.
+
+=back
=head1 AUTHOR
You will need to set an expression value and you may set any of the
following:
-=over 4
+=over
+
+=item *
-=item constants
+constants
A hashref defining extra constants for expression parsing. The names
of the constants must be valid identifiers (/[^\W\d]\w*/) and the
Imager::Expr may define it's own constants (currently just pi.)
-=item variables
+=item *
+
+variables
A reference to an array of variable names. These are allocated
numeric registers starting from register zero.
Methods used by parsers:
-=over 4
+=over
+
+=item compile
+
+This is the main method you'll need to implement in a parser. See the
+existing parsers for a guide.
+
+It's supplied the following parameters:
+
+=over
+
+=item *
+
+$expr - the expression to be parsed
+
+=item *
+
+$options - the options hash supplied to transform2.
+
+=back
+
+Return an array ref of array refs containing opcodes and operands.
=item @vars = $self->_variables()
Converts marginally parsed RPN to register code.
+=item assemble
+
+Called to convert op codes into byte code.
+
+=item numre
+
+Returns a regular expression that matches floating point numbers.
+
+=item optimize
+
+Optimizes the assembly code, including attempting common subexpression
+elimination and strength reducing division by a constant into
+multiplication by a constant.
+
+=item register_type
+
+Called by a new expression parser implementation to register itself,
+call as:
+
+ YourClassName->register_type('type code');
+
+where type code is the parameter that will accept the expression.
+
=back
=head2 Future compatibility
the code reference stored in C<$Imager::FORMATGUESS>. This is only
done when write() or write_multi() is called with a C<file> parameter.
-The default function examines the extension of the filename to guess
-the type.
+The default function value of C<$Imager::FORMATGUESS> is
+C<\&Imager::def_guess_type>.
+
+=over
+
+=item def_guess_type
+
+This is the default function Imager uses to derive a file type from a
+file name. This is a function, not a method.
+
+Accepts a single parameter, the filename and returns the type or
+undef.
+
+=back
You can replace function with your own implementation if you have some
specialized need. The function takes a single parameter, the name of
=head1 DESCRIPTION
-Creates fill objects for use by some drawing functions, currently just
-the Imager box() method.
+Creates fill objects for use by most filled area drawing functions.
+
+All fills are created with the new method.
+
+=over
+
+=item new
+
+ my $fill = Imager::Fill=>new(...);
+
+The parameters depend on the type of fill being created. See below
+for details.
+
+=back
The currently available fills are:
Both Freetype 1.x and 2.x allow support for glyph names to not be
included.
+=item draw
+
+This is used by Imager's string() method to implement drawing text.
+See L<Imager::Draw/string>.
+
=back
=head1 MULTIPLE MASTER FONTS
your font doesn't support it, Imager will I<not> build it from 0041
"LATIN CAPITAL LETTER A" and 0308 "COMBINING DIAERESIS".
+To check if a driver supports UTF8 call the utf8 method:
+
+=over
+
+=item utf8
+
+Return true if the font supports UTF8.
+
+=back
+
=head2 Native UTF8 Support
If your version of perl supports UTF8 and the driver supports UTF8,
list is used to choose which one should be used, if a given format can
be handled by more than one driver.
-The current priority can be retrieved with:
+=over
+
+=item priorities
+
+The current priorities can be retrieved with:
@drivers = Imager::Font->priorities();
@old = Imager::Font->priorities(@drivers);
+=back
+
If you supply driver names that are not currently supported, they will
be ignored.
=item start_offset()
+=item neg_width
+
+=item left_bearing
+
Returns the horizonatal offset from the selected drawing location to
the left edge of the first character drawn. If this is positive, the
first glyph is to the right of the drawing location.
return $_[0][0];
}
-=item end_offset()
+=item end_offset
+
+=item pos_width
The offset from the selected drawing location to the right edge of the
last character drawn. Should always be positive.
or set C<savepos> to see how much text can fit within the given
C<height>.
-=head1 OPTIONS
+=over
+
+=item wrap_text
+
+Draw word-wrapped text.
=over
Any other parameters are passed onto Imager::Font->draw().
-=head1 RETURNS
-
Returns a list:
($left, $top, $right, $bottom)
width => $xsize,
image => $image);
+=back
+
=head1 BUGS
Imager::Font can handle UTF8 encoded text itself, but this module
--- /dev/null
+=head1 NAME
+
+Imager::Handy - simple access to common functions
+
+=head1 SYNOPSIS
+
+ use Imager ':handy';
+ my $color = NC(255, 0, 0);
+ my $font = NF(1.0, 0, 0);
+
+=head1 DESCRIPTION
+
+If you use Imager with the C<:handy> import tag, it will export a
+number of functions that can shorter your code.
+
+=over
+
+=item NC
+
+=item newcolor
+
+=item newcolour
+
+Create a new Imager::Color object, supplying any parameters to the
+new() method.
+
+ my $color = NC('red');
+
+=item NF
+
+=item newfont
+
+Create a new Imager::Font object, supplying any parameters to the
+new() method.
+
+ my $font = NF(file => 'foo.ttf');
+
+=back
+
+=head1 BUGS
+
+NC() can be mostly replaced by supplying the color name or other
+description directly to the drawing method.
+
+=head1 AUTHOR
+
+Tony Cook <tony@imager.perl.org>
+
+=cut
+
=back
+=head1 INITIALIZATION
+
+This documents the Imager initialization function, which you will
+almost never need to call.
+
+=over
+
+=item init
+
+This is a function, not a method.
+
+This function is a mess, it can take the following named parameters:
+
+=over
+
+=item *
+
+log - name of a log file to log Imager's actions to. Not all actions
+are logged, but the debugging memory allocator does log allocations
+here. Ignored if Imager has been built without logging support.
+
+=item *
+
+loglevel - the maximum level of message to log. Default: 1.
+
+=item *
+
+warn_obsolete - if this is non-zero then Imager will warn when you
+attempt to use obsoleted parameters or functionality. This currently
+only includes the old gif output options instead of tags.
+
+=item *
+
+t1log - if non-zero then T1lib will be configured to produce a log
+file. This will fail if there are any existing T1lib font objects.
+
+=back
+
+Example:
+
+ Imager::init(log => 'trace.log', loglevel => 9);
+
+=back
+
=head1 REVISION
$Revision$
eval "use Test::Pod::Coverage 1.08;";
# 1.08 required for coverage_class support
plan skip_all => "Test::Pod::Coverage 1.08 required for POD coverage" if $@;
-plan tests => 1;
# scan for a list of files to get Imager method documentation from
my $manifest = maniread();
my @pods = ( 'Imager.pm', grep /\.pod$/, keys %$manifest );
-my @private = ( '^io?_', '^DSO_', '^Inline$', '^yatf$', '^m_init_log$' );
-my @trustme = ( '^errstr$', '^open$' );
+my @private =
+ (
+ '^io?_',
+ '^DSO_',
+ '^Inline$',
+ '^yatf$',
+ '^m_init_log$',
+ '^malloc_state$',
+ '^init_log$',
+ '^polybezier$', # not ready for public consumption
+ );
+my @trustme = ( '^open$', );
-TODO: {
- local $TODO = "Still working on method coverage";
+plan tests => 11;
+
+{
pod_coverage_ok('Imager', { also_private => \@private,
pod_from => \@pods,
trustme => \@trustme,
- coverage_class => 'Pod::Coverage::Imager' },
- "Imager");
-
+ coverage_class => 'Pod::Coverage::Imager' });
+ pod_coverage_ok('Imager::Font');
+ my @color_private = ( '^i_', '_internal$' );
+ pod_coverage_ok('Imager::Color',
+ { also_private => \@color_private });
+ pod_coverage_ok('Imager::Color::Float',
+ { also_private => \@color_private });
+ pod_coverage_ok('Imager::Color::Table');
+ pod_coverage_ok('Imager::ExtUtils');
+ pod_coverage_ok('Imager::Expr');
+ my $trust_parents = { coverage_class => 'Pod::Coverage::CountParents' };
+ pod_coverage_ok('Imager::Expr::Assem', $trust_parents);
+ pod_coverage_ok('Imager::Fill');
+ pod_coverage_ok('Imager::Font::BBox');
+ pod_coverage_ok('Imager::Font::Wrap');
}