# ... $image is your GD::Image for output my $gd = $image->gd; my @attrs = unpack 'nnnCV', substr( $gd, 0, 11, '' ); my $len = length( $gd ) / 4 * 3; my $bmp = pack 'a2 V V V l< l< l< v v V V l< l< V V', 'BM', $len + 54, 0, 54, 40, $attrs[1], $attrs[2], 1, 24, $len, 0, 0, 0, 0; $bmp .= join'', unpack '(xaaa)*', $gd; ## Now print $bmp to a file xxx.bmp and convert; or maybe pipe directly to an image converter for conversion.