NAME
Image::Square - Crop and resize an image to create a square image
SYNOPSIS
use Image::Square;
# Create a new Image::Square object from an image file
my $img = Image::Square->new('example.jpg');
# Create a square image from the source image with default settings
my $square_img = $img->square();
# Create a square image of a specific size (e.g., 200x200 pixels)
my $custom_size_square = $img->square(200);
# Create a square image from a specific position (e.g., center)
my $center_square = $img->square(0, 0.5);
DESCRIPTION
The Image::Square
module provides a simple way to crop and resize an image to create a square image. This can be useful when you need to prepare images for applications that require square thumbnails or avatars.
METHODS
new
my $img = Image::Square->new('example.jpg');
Creates a new Image::Square
object from an image file specified by the file path. The image file should be in a format supported by the GD module. Alternatively, a GD::Image object is accepted.
square
my $square_img = $img->square($size, $pos);
Creates a square image from the source image. The method takes two optional parameters:
$size
- The size of the output square image in pixels. If not provided or set to 0, the size will be determined based on the smaller dimension of the source image. (default: 0)$pos
- The position in the source image to create the square image from. This parameter accepts values between 0 and 1, where 0 represents the left or top edge, 0.5 represents the middle, and 1 represents the right or bottom edge. (default: 0.5)
The method returns a new GD::Image object that represents the square image.
AUTHOR
Ian Boddison <ian at boddison.com>
BUGS
Please report any bugs or feature requests to bug-image-square at rt.cpan.org
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=image-square. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Image::Square
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
Search CPAN
COPYRIGHT AND LICENSE
This software is copyright (c) 2023 by Ian Boddison.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.