Resize all images in a directory. Images should be of the format xxx_WIDTHxHEIGHT.ext, so bla_2048x1536.png, run as : ./cut50.pl 2048 1536 and all images are resized to 1024x768.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
$x = $ARGV[0]; | |
$y = $ARGV[1]; | |
if (not $x or not $y) { | |
print "./cut50.pl width height\n"; | |
exit; | |
} | |
$fv = "_$x"."x"."$y"."\\."; | |
$nx = int($x / 2); | |
$ny = int($y / 2); | |
foreach(glob("*.*")) { | |
chomp; | |
$f = $_; | |
next if not /$fv/; | |
/^(.*?)$fv(.*)$/; | |
$nn = $1."_".$nx."x".$ny.".".$2; | |
print `convert "$f" -resize 50% "$nn"`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment