Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use strict; # Enforce some good programming rules
- use Image::Magick; # Module for image processing
- my $ratio = 1/3;
- my $image = Image::Magick->new; # create object
- foreach (@ARGV) {
- opendir(DIR, $_) or die "Can't opendir $_: $!";
- while (defined(my $file = readdir(DIR))) {
- if ($file =~ m/.jpg$/i){ # skip if not a JPEG file
- my $path = "$_/$file";
- ## Image processing
- $image -> Read($path);
- my $width = $image->Get('columns');
- my $height = $image->Get('height');
- $image -> Resize(width => ($width * $ratio),
- height => ($height * $ratio),
- );
- $image -> Write(filename => $path);
- undef @$image; # delete image
- }
- }
- closedir(DIR);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement