use strict; use warnings; use Image::Magick; my $image = Image::Magick->new( size => '1024x100', type => 'Greyscale', depth => 16, ); $image->Read('xc:white'); for ( 0 .. 1023 ) { my $color = sprintf "gray(%2.3f%%)", 100 * $_ / 1023; my $res = $image->Draw( primitive => 'line', stroke => $color, points => "$_,0 $_,100", ); warn $res if $res; } for ( 0 .. 16 ) { $image->SetPixel( x => int( (16 - $_) * 1023 / 16 ), y => 50, color => [ ( $_ / 16 ) x 3 ], ); } my $res = $image->Write( filename => "grey.png" ); warn $res if $res;