The Perl Toolchain Summit 2025 Needs You: You can help 🙏 Learn more

NAME
Data::FormValidator::Filters::Image - Filter that allows you to shrink
incoming image uploads using Data::FormValidator
SYNOPSIS
use Data::FormValidator::Filters::Image qw( image_filter );
# Build a Data::FormValidator Profile:
my $my_profile = {
required => qw( uploaded_image ),
field_filters => {
uploaded_image => image_filter(max_width => 800, max_height => 600),
},
};
# Be sure to use a CGI.pm object as the form input
# when using this filter
my $q = new CGI;
my $dfv = Data::FormValidator->check($q,$my_profile);
DESCRIPTION
Many users when uploading image files never bother to shrink them down
to a reasonable size. Instead of declining the upload because it is too
large, this module will shrink the image down to a reasonable size
during the form validation stage.
The filter will try to fail gracefully by leaving the upload as is if
the image resize operation fails.
FILTERS
image_filter( max_width => $width, max_height => $height )
This will create a filter that will reduce the size of an image that is
being uploaded so that it is bounded by the width and height provided.
The image will be scaled in a way that will not distort or stretch the
image.
example:
- upload an image that is 800 x 600
- specify a max width of 100 and max height of 100
The resulting image will be 100 x 75, since that is the
largest scaled image we can create that is still within
the bounds we specified.
SEE ALSO
Data::FormValidator
AUTHOR
Cees Hek <ceeshek@gmail.com>
CREDITS
Thanks to SiteSuite (http://www.sitesuite.com.au) for funding the
development of this plugin and for releasing it to the world.
LICENCE AND COPYRIGHT
Copyright (c) 2005, SiteSuite. All rights reserved.
This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.THE
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/ORREDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
ORCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.