Bitmap/PPM conversion through a pipe: Difference between revisions
Bitmap/PPM conversion through a pipe (view source)
Revision as of 18:30, 24 December 2021
, 2 years agoadded Perl programming solution
m (→{{header|Phix}}: added syntax colouring, marked p2js incompatible) |
(added Perl programming solution) |
||
Line 236:
with End_of_file -> ()
;;</lang>
=={{header|Perl}}==
<lang perl># 20211224 Perl programming solution
use strict;
use warnings;
use Imager;
use Imager::Test 'test_image_raw';
my $img = test_image_raw();
my $IO = Imager::io_new_bufchain();
Imager::i_writeppm_wiol($img, $IO) or die;
my $raw = Imager::io_slurp($IO) or die;
open my $fh, '|-', '/usr/local/bin/convert - -compress none output.jpg' or die;
binmode $fh;
syswrite $fh, $raw or die;
close $fh;</lang>
{{out}}
<pre>file output.jpg
output.jpg: JPEG image data, JFIF standard 1.01, comment: "CREATOR: Imager"
magick identify output.jpg
output.jpg JPEG 150x150 150x150+0+0 8-bit sRGB 3952B 0.000u 0:00.012</pre>
=={{header|Phix}}==
|