Image::Random - Perl class for creating random image.
use Image::Random; my $obj = Image::Random->new(%parameters); my $type = $obj->create($output_path); my ($width, $height) = $obj->sizes($new_width, $new_height); my $type = $obj->type($new_type);
new
my $obj = Image::Random->new(%parameters);
Constructor.
color
Color of image. Default value is undef. Undefined value means random color.
height
Height of image. Default value is 1920.
type
Image type. List of supported types: bmp, gif, jpeg, png, pnm, raw, sgi, tga, tiff Default value is 'bmp'.
width
Width of image. Default value is 1080.
create
my $type = $obj->create($output_path);
Create image.
Returns scalar value of supported file type.
sizes
my ($width, $height) = $obj->sizes($new_width, $new_height);
Set/Get image sizes.
Both parameters are optional, used only for set sizes.
Returns actual width and height.
my $type = $obj->type($new_type);
Set/Get image type.
Parameter $new_type is optional, used only for setting.
Returns actual type of image.
new(): Bad background color definition. Use Imager::Color object. Image type '%s' doesn't supported. From Class::Utils: Unknown parameter '%s'. create(): Cannot write file to '$path'. Error, %s Image type '%s' doesn't supported.
use strict; use warnings; use File::Temp qw(tempfile); use Image::Random; # Temporary file. my (undef, $temp) = tempfile(); # Object. my $obj = Image::Random->new; # Create image. my $type = $obj->create($temp); # Print out type. print $type."\n"; # Unlink file. unlink $temp; # Output: # bmp
Class::Utils, Error::Pure, File::Basename, Imager, Imager::Color, List::MoreUtils.
Perl module to generate random data
Perl class for creating random image.
https://github.com/michal-josef-spacek/Image-Random.
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© 2013-2020 Michal Josef Špaček
BSD 2-Clause License
0.09
To install Image::Random, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Image::Random
CPAN shell
perl -MCPAN -e shell install Image::Random
For more information on module installation, please visit the detailed CPAN module installation guide.