use Imager; my $i = Imager->new(); $nfr = reverse $nfr; $i->read( type => "pnm", data => "P6\n$width $height\n255\n" . $nfr ); $i->flip(dir => "hv");