parse-wormedit: convert pbm format to monochrome pnm
authorMischa Poslawsky <wormy@shiar.org>
Mon, 26 Oct 2020 21:32:42 +0000 (22:32 +0100)
committerMischa Poslawsky <wormy@shiar.org>
Mon, 26 Oct 2020 22:35:49 +0000 (23:35 +0100)
Imager determines pnm subtype only by number of channels,
so reduce the palette to obtain a P4 format as requested.

parse-wormedit

index 721cec841e15a519862aae501dd8d7484550ec7c..cf1798d6a25e6cb787b9836577add8782ec93aed 100755 (executable)
@@ -162,6 +162,10 @@ default {
        my $img = Games::Wormy::Render->composite(
                map { $data->{levels}->[$_] } @request
        ) or die "empty result for levels\n";
+       if ($opt{format} ~~ 'pbm') {
+               $img = $img->to_paletted({make_colors => 'mono'});
+               $opt{format} = 'pnm';
+       }
        $img->write(
                $opt{output} ? (file => $opt{output}) : (fh => \*STDOUT),
                type => $opt{format} // 'pnm',