Add Small Perl Script to download and resize images

This commit is contained in:
Justin Hammond 2019-06-01 12:25:58 +08:00
parent 2723540bbb
commit 5c106c608d

19
tools/imagedownload.pl Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/perl -w
use Image::Resize;
use File::Fetch;
use POSIX;
use open qw/ :std :encoding(utf-8) /;
BEGIN { $| = 1; }
my $imgurl = $ARGV[0];
print "Downloading $imgurl....";
my $download = File::Fetch->new(uri => $imgurl);
my $file = $download->fetch() or die $download->error;
File::Copy::move($file, 'productimage.png');
print "Done\n\nResizing....";
my $img = Image::Resize->new('productimage.png');
my $gd = $img->resize(200,200);
$gd->_file('productimage.png');
print "Done\n\nSaved as productimage.png\n";