01 Dec 2017 19:49:03 UTC
- Distribution: Image-JPEG-Size
- Module version: 0.02
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (403 / 0 / 27)
- KwaliteeBus factor: 0
- % Coverage
- License: unknown
- Activity24 month
- Download (41.49KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
Why not adopt me?This distribution is up for adoption! If you're interested then please contact the PAUSE module admins via email.
- ERROR HANDLING
Image::JPEG::Size - find the size of JPEG images
use Image::JPEG::Size; my $jpeg_sizer = Image::JPEG::Size->new; my ($width, $height) = $jpeg_sizer->file_dimensions($filename);
This module uses libjpeg to rapidly determine the size of one or more JPEG images.
First create an instance of the class:
my $jpeg_sizer = Image::JPEG::Size->new;
The constructor initialises internal libjpeg structures; if that fails, an exception is thrown.
The constructor takes attributes as either a hash reference or a listified hash. Unknown attributes are ignored. The following attributes are understood:
Specifies the action to take on encountering a non-recoverable error in an image; see "ERROR HANDLING". Defaults to
Specifies the action to take on encountering a recoverable error in an image; see "ERROR HANDLING". Defaults to
You can repeatedly call
file_dimensionsin list context to find the width and height of your JPEG images:
my ($width, $height) = $jpeg_sizer->file_dimensions($filename);
For now, the JPEG images must be supplied as a filename.
In some cases, you may prefer to get the image dimensions as a hash. The
file_dimensions_hashtakes a single filename argument, and returns a listified hash with keys
By default, recoverable errors in the image are reported using Perl's warning mechanism, and non-recoverable errors cause an exception to be thrown. However, this behaviour can be changed when creating an Image::JPEG::Size instance. The options are:
Throw an exception with information about the error, and stop processing this image immediately.
Emit a Perl warning with information about the error. If the error is non-recoverable, image processing stops immediately, and its dimensions are reported as 0×0 pixels.
Suppress the error entirely. If the error is non-recoverable, image processing stops immediately, and its dimensions are reported as 0×0 pixels.
Aaron Crane, <email@example.com>
The initial development of this module was sponsored by Science Photo Library https://www.sciencephoto.com/.
Copyright 2017 Aaron Crane.
This library is free software and may be distributed under the same terms as perl itself. See http://dev.perl.org/licenses/.
Module Install Instructions
To install Image::JPEG::Size, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Image::JPEG::Size
For more information on module installation, please visit the detailed CPAN module installation guide.