clean up various testout directories on a make clean
[imager.git] / JPEG / JPEG.pm
CommitLineData
797a9f9c
TC
1package Imager::File::JPEG;
2use strict;
3use Imager;
4use vars qw($VERSION @ISA);
5
6BEGIN {
7 $VERSION = "0.77";
8
9 eval {
10 require XSLoader;
11 XSLoader::load('Imager::File::JPEG', $VERSION);
12 1;
13 } or do {
14 require DynaLoader;
15 push @ISA, 'DynaLoader';
16 bootstrap Imager::File::JPEG $VERSION;
17 };
18}
19
20Imager->register_reader
21 (
22 type=>'jpeg',
23 single =>
24 sub {
25 my ($im, $io, %hsh) = @_;
26
27 ($im->{IMG},$im->{IPTCRAW}) = i_readjpeg_wiol( $io );
28
29 unless ($im->{IMG}) {
30 $im->_set_error(Imager->_error_as_msg);
31 return;
32 }
33 return $im;
34 },
35 );
36
37Imager->register_writer
38 (
39 type=>'jpeg',
40 single =>
41 sub {
42 my ($im, $io, %hsh) = @_;
43
44 $im->_set_opts(\%hsh, "i_", $im);
45 $im->_set_opts(\%hsh, "jpeg_", $im);
46 $im->_set_opts(\%hsh, "exif_", $im);
47
48 my $quality = $hsh{jpegquality};
49 defined $quality or $quality = 75;
50
51 if ( !i_writejpeg_wiol($im->{IMG}, $io, $quality)) {
52 $im->_set_error(Imager->_error_as_msg);
53 return;
54 }
55
56 return $im;
57 },
58 );
59
60__END__
61
62=head1 NAME
63
64Imager::File::JPEG - read and write JPEG files
65
66=head1 SYNOPSIS
67
68 use Imager;
69
70 my $img = Imager->new;
71 $img->read(file=>"foo.jpg")
72 or die $img->errstr;
73
74 $img->write(file => "foo.jpg")
75 or die $img->errstr;
76
77=head1 DESCRIPTION
78
79Imager's JPEG support is documented in L<Imager::Files>.
80
81=head1 AUTHOR
82
83Tony Cook <tony@imager.perl.org>
84
85=head1 SEE ALSO
86
87Imager, Imager::Files.
88
89=cut