package Imager;
use strict;
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS %formats $DEBUG %filters %DSOs $ERRSTR $fontstate %OPCODES $I2P $FORMATGUESS $warn_obsolete);
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS %formats $DEBUG %filters %DSOs $ERRSTR %OPCODES $I2P $FORMATGUESS $warn_obsolete);
use IO::File;
use Imager::Color;
BEGIN {
require Exporter;
@ISA = qw(Exporter);
- $VERSION = '0.77_01';
+ $VERSION = '0.80';
eval {
require XSLoader;
XSLoader::load(Imager => $VERSION);
gif => "Imager::File::GIF",
tiff => "Imager::File::TIFF",
jpeg => "Imager::File::JPEG",
+ w32 => "Imager::Font::W32",
+ ft2 => "Imager::Font::FT2",
);
tie %formats, "Imager::FORMATS", \%formats_low, \%format_classes;
BEGIN {
- Imager::Font::__init();
for(i_list_formats()) { $formats_low{$_}++; }
- if (!$formats_low{'t1'} and !$formats_low{'tt'}
- && !$formats_low{'ft2'} && !$formats_low{'w32'}) {
- $fontstate='no font support';
- }
%OPCODES=(Add=>[0],Sub=>[1],Mult=>[2],Div=>[3],Parm=>[4],'sin'=>[5],'cos'=>[6],'x'=>[4,0],'y'=>[4,1]);
$DEBUG=0;
$result->{IMG} = i_img_masked_new($self->{IMG}, $mask, $opts{left},
$opts{top}, $opts{right} - $opts{left},
$opts{bottom} - $opts{top});
+ unless ($result->{IMG}) {
+ $self->_set_error(Imager->_error_as_msg);
+ return;
+ }
+
# keep references to the mask and base images so they don't
# disappear on us
$result->{DEPENDS} = [ $self->{IMG}, $mask ];
- $result;
+ return $result;
}
# convert an RGB image into a paletted image
return $new;
}
+# combine channels from multiple input images, a class method
+sub combine {
+ my ($class, %opts) = @_;
+
+ my $src = delete $opts{src};
+ unless ($src) {
+ $class->_set_error("src parameter missing");
+ return;
+ }
+ my @imgs;
+ my $index = 0;
+ for my $img (@$src) {
+ unless (eval { $img->isa("Imager") }) {
+ $class->_set_error("src must contain image objects");
+ return;
+ }
+ unless ($img->{IMG}) {
+ $class->_set_error("empty input image");
+ return;
+ }
+ push @imgs, $img->{IMG};
+ }
+ my $result;
+ if (my $channels = delete $opts{channels}) {
+ $result = i_combine(\@imgs, $channels);
+ }
+ else {
+ $result = i_combine(\@imgs);
+ }
+ unless ($result) {
+ $class->_set_error($class->_error_as_msg);
+ return;
+ }
+
+ my $img = $class->new;
+ $img->{IMG} = $result;
+
+ return $img;
+}
+
# general function to map an image through lookup tables
sub newcolor { Imager::Color->new(@_); }
sub newfont { Imager::Font->new(@_); }
-sub NCF { Imager::Color::Float->new(@_) }
+sub NCF {
+ require Imager::Color::Float;
+ return Imager::Color::Float->new(@_);
+}
*NC=*newcolour=*newcolor;
*NF=*newfont;
my $format;
# see Imager::Files for information on the read() method
- my $im = Imager->new(file=>$file)
+ my $img = Imager->new(file=>$file)
or die Imager->errstr();
$file =~ s/\.[^.]*$//;
colorcount() - L<Imager::Draw/colorcount> - the number of colors in an
image's palette (paletted images only)
+combine() - L<Imager::Transformations/combine> - combine channels from one or
+more images.
+
combines() - L<Imager::Draw/combines> - return a list of the different
combine type keywords
changes between image - L<Imager::Filters/"Image Difference">
+channels, combine into one image - L<Imager::Transformations/combine>
+
color - L<Imager::Color>
color names - L<Imager::Color>, L<Imager::Color::Table>
tiles, color - L<Imager::Filters/mosaic>
+transparent images - L<Imager::ImageTypes>,
+L<Imager::Cookbook/"Transparent PNG">
+
=for stopwords unsharp
unsharp mask - L<Imager::Filters/unsharpmask>
Many others have contributed to Imager, please see the C<README> for a
complete list.
+=head1 LICENSE
+
+Imager is licensed under the same terms as perl itself.
+
+=for stopwords
+makeblendedfont Fontforge
+
+A test font, FT2/fontfiles/MMOne.pfb, contains a Postscript operator
+definition copyrighted by Adobe. See F<adobe.txt> in the source for
+license information.
+
=head1 SEE ALSO
L<perl>(1), L<Imager::ImageTypes>(3), L<Imager::Files>(3),