use strict; use warnings; use Imager; use constant IMAGESIZE => 300; # RBGA use constant ROSYBROWN => 0xBC8F8FFF; my @result = map { # make us some picture to find when ( ROSYBROWN ) x $_, # examining output, let it be random int( rand 0xFFFFFFFF ), # colour diagonal on uniform BG ( ROSYBROWN ) x ( IMAGESIZE - $_ - 1 ), } 0 .. IMAGESIZE - 1; my $img = Imager-> new( type => 'raw', xsize => IMAGESIZE, ysize => IMAGESIZE, data => pack( 'L>*', @result ), raw_interleave => 0, raw_datachannels => 4, raw_storechannels => 4, ); $img->write(file=>'out.png');