package Imager::File::JPEG; use 5.006; use strict; use Imager; BEGIN { our $VERSION = "1.005"; require XSLoader; XSLoader::load('Imager::File::JPEG', $VERSION); } Imager->register_reader ( type=>'jpeg', single => sub { my ($im, $io, %hsh) = @_; ($im->{IMG},$im->{IPTCRAW}) = i_readjpeg_wiol( $io ); unless ($im->{IMG}) { $im->_set_error(Imager->_error_as_msg); return; } return $im; }, ); Imager->register_writer ( type=>'jpeg', single => sub { my ($im, $io, %hsh) = @_; $im->_set_opts(\%hsh, "i_", $im); $im->_set_opts(\%hsh, "jpeg_", $im); $im->_set_opts(\%hsh, "exif_", $im); my $quality = $hsh{jpegquality}; defined $quality or $quality = 75; if ( !i_writejpeg_wiol($im->{IMG}, $io, $quality)) { $im->_set_error(Imager->_error_as_msg); return; } return $im; }, ); sub has_arith_coding { my $cls = shift; return $cls->has_encode_arith_coding && $cls->has_decode_arith_coding; } __END__ =head1 NAME Imager::File::JPEG - read and write JPEG files =head1 SYNOPSIS use Imager; my $img = Imager->new; $img->read(file=>"foo.jpg") or die $img->errstr; $img->write(file => "foo.jpg") or die $img->errstr; my $version = Imager::File::JPEG->libjpeg_version(); if (Imager::File::JPEG->is_turbojpeg) { ... } if (Imager::File::JPEG->is_mozjpeg) { ... } if (Imager::File::JPEG->has_arith_coding) { ... } =head1 DESCRIPTION Imager's JPEG support is documented in L. Besides providing JPEG support, Imager::File::JPEG has the following methods: =over =item libjpeg_version() Imager::File::JPEG->libjpeg_version(); Returns version information about the variety of C Imager::File::JPEG was compiled with. This is determined at build time. This includes: =over =item * The library type, one of C, C or C. =item * C followed by the library version number. =item * C followed by the C API version. =back For C the API and library versions are always equal. =item is_turbojpeg() Imager::File::JPEG->is_turbojpeg(); Returns true if Imager::File::JPEG was built with C. Note that C is built on top of C so this will return true for C. =item is_mozjpeg() Imager::File::JPEG->is_mozjpeg(); Returns true if Imager::File::JPEG was built with C. Note that C doesn't define its own version numbering, so C is detected by defines that only C currently defines. =item has_arith_coding() Returns true if the C variant C was built with has both encoding and decoding support for arithmetic coding. =item has_encode_arith_coding() Returns true if the C variant C was built with has encoding support for arithmetic coding. =item has_decode_arith_coding() Returns true if the C variant C was built with has decoding support for arithmetic coding. =back =head1 AUTHOR Tony Cook =head1 SEE ALSO Imager, Imager::Files. =cut