Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Resize all images in a directory. Images should be of the format xxx_WIDTHxHEIGHT.ext, so bla_2048x1536.png, run as : ./ 2048 1536 and all images are resized to 1024x768.
$x = $ARGV[0];
$y = $ARGV[1];
if (not $x or not $y) {
print "./ width height\n";
$fv = "_$x"."x"."$y"."\\.";
$nx = int($x / 2);
$ny = int($y / 2);
foreach(glob("*.*")) {
$f = $_;
next if not /$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