TIFF: fix some format string/argument type mismatches
[imager.git] / TIFF / TIFF.pm
CommitLineData
e5ee047b
TC
1package Imager::File::TIFF;
2use strict;
3use Imager;
4use vars qw($VERSION @ISA);
5
6BEGIN {
cd496c63 7 $VERSION = "0.87";
e5ee047b 8
a5919365
TC
9 require XSLoader;
10 XSLoader::load('Imager::File::TIFF', $VERSION);
e5ee047b
TC
11}
12
13Imager->register_reader
14 (
15 type=>'tiff',
16 single =>
17 sub {
18 my ($im, $io, %hsh) = @_;
19
20 my $allow_incomplete = $hsh{allow_incomplete};
21 defined $allow_incomplete or $allow_incomplete = 0;
22
23 my $page = $hsh{page};
24 defined $page or $page = 0;
25 $im->{IMG} = i_readtiff_wiol($io, $allow_incomplete, $page);
26
27 unless ($im->{IMG}) {
28 $im->_set_error(Imager->_error_as_msg);
29 return;
30 }
31
32 return $im;
33 },
34 multiple =>
35 sub {
36 my ($io, %hsh) = @_;
37
38 my @imgs = i_readtiff_multi_wiol($io);
39 unless (@imgs) {
40 Imager->_set_error(Imager->_error_as_msg);
41 return;
42 }
43
44 return map bless({ IMG => $_, ERRSTR => undef }, "Imager"), @imgs;
45 },
46 );
47
48Imager->register_writer
49 (
50 type=>'tiff',
51 single =>
52 sub {
53 my ($im, $io, %hsh) = @_;
54
55 $im->_set_opts(\%hsh, "i_", $im);
56 $im->_set_opts(\%hsh, "tiff_", $im);
57 $im->_set_opts(\%hsh, "exif_", $im);
58
59 if (defined $hsh{class} && $hsh{class} eq "fax") {
60 my $fax_fine = $hsh{fax_fine};
61 defined $fax_fine or $fax_fine = 1;
62 if (!i_writetiff_wiol_faxable($im->{IMG}, $io, $fax_fine)) {
63 $im->{ERRSTR} = Imager->_error_as_msg();
64 return undef;
65 }
66 }
67 else {
68 unless (i_writetiff_wiol($im->{IMG}, $io)) {
69 $im->_set_error(Imager->_error_as_msg);
70 return;
71 }
72 }
73 return $im;
74 },
75 multiple =>
76 sub {
77 my ($class, $io, $opts, @ims) = @_;
78
79 Imager->_set_opts($opts, "tiff_", @ims);
80 Imager->_set_opts($opts, "exif_", @ims);
81
82 my @work = map $_->{IMG}, @ims;
83 my $tiff_class = $opts->{class};
84 defined $tiff_class or $tiff_class = "";
85
86 my $result;
87 if ($tiff_class eq "fax") {
88 my $fax_fine = $opts->{fax_fine};
89 defined $fax_fine or $fax_fine = 1;
90 $result = i_writetiff_multi_wiol_faxable($io, $fax_fine, @work);
91 }
92 else {
93 $result = i_writetiff_multi_wiol($io, @work);
94 }
95 unless ($result) {
96 $class->_set_error($class->_error_as_msg);
97 return;
98 }
99
100 return 1;
101 },
102 );
103
104__END__
105
106=head1 NAME
107
108Imager::File::TIFF - read and write TIFF files
109
110=head1 SYNOPSIS
111
112 use Imager;
113
114 my $img = Imager->new;
115 $img->read(file=>"foo.tiff")
116 or die $img->errstr;
117
118 $img->write(file => "foo.tif")
119 or die $img->errstr;
120
121=head1 DESCRIPTION
122
123Imager's TIFF support is documented in L<Imager::Files>.
124
125=head1 AUTHOR
126
5b480b14 127Tony Cook <tonyc@cpan.org>
e5ee047b
TC
128
129=head1 SEE ALSO
130
131Imager, Imager::Files.
132
133=cut