#!/usr/bin/perl
#

use strict;
use warnings;
use IO::Handle;
use Image::Magick;

my @sizes=("800", "1024", "1280", "1440");

my $dh=IO::Handle->new();
opendir($dh, ".") || die "Failed to open this directory, $!\n";
while (my $file=readdir($dh))
{
	next if $file !~ /^Node_Assassin_v1\.2\.1_(.*?)\.png$/;
	print "File: [$file]\n";
	
	my $image = new Image::Magick;
	$image->Read("$file");
	my ($origw, $origh) = $image->Get('width', 'height');

	foreach my $new_size (@sizes)
	{
		my $new_file=$file;
		$new_file=~s/^(Node_Assassin_v1\.2\.1_)(.*?)/${1}${new_size}_$2/;
		
		my $width = $new_size;
		my $height = int($width * $origh / $origw);
		print " - [$origw x $origh] -> [$width x $height] ($new_file)\n";
		
		$image->Resize(width=>$width, height=>$height);
		my $out_file="Node_Assassin_v1.2.1_$new_size/$new_file";
		$image->Write($out_file);
	}
}
$dh->close();

exit 0;

