sub rotate { my ($img, $path) = @_; my @degrees = qw(45 90 135 180 225 270 315); my $cropped_orig = crop_image($img); my %images = (0 => $cropped_orig); foreach (@degrees) { my $image = GD::Image->new(CANVAS, CANVAS); $image->copyRotated($img, 32, 32, 1, 1, 64, 64, $_); $image = crop_image($image); $images{$_} = $image; } return \%images; }