Data::Validate::Image - Validates an image and returns basic info
use Data::Validate::Image; my $validator = Data::Validate::Image->new(); my $image_info = $validator->validate( '/path/to/image' ); if ( defined( $image_info ) ){ #valid image, do things here } else { #invalid image }
A simple image validator class, which provides a single validate method that upon success returns a hash ref of image properties:
validate
{ 'width' => 'image width', 'height' => 'image height', 'size' => 'image filesize (KB)', 'mime' => 'image mime type', 'file_ext' => '*correct* file extenstion', 'frames' => 'frame count', # requires convert from ImageMagick 'animated' => 1 || 0, # requires convert from ImageMagick }
For invalid images the validate method returns undef.
undef
REQUIRES convert (from ImageMagick) to detect the frames and animated properties.
frames
animated
I used convert over PerlMagick because I found PerlMagick to be very unstable.
Returns image properties for valid image or C<undef> for invalid image
Mark Ellis <markellis@cpan.org>
j1n3l0 - Nelo Onyiah - <nelo.onyiah@gmail.com>
Image::Info
Copyright 2015 Mark Ellis <markellis@cpan.org>
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
To install Data::Validate::Image, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Validate::Image
CPAN shell
perl -MCPAN -e shell install Data::Validate::Image
For more information on module installation, please visit the detailed CPAN module installation guide.