Bitmap/Read an image through a pipe: Difference between revisions
Bitmap/Read an image through a pipe (view source)
Revision as of 17:21, 26 December 2021
, 2 years agoadded Perl programming solution
m (→{{header|Phix}}: added syntax colouring, marked p2js incompatible) |
(added Perl programming solution) |
||
Line 338:
(img)
;;</lang>
=={{header|Perl}}==
<lang perl># 20211226 Perl programming solution
use strict;
use warnings;
use Imager;
my $raw;
open my $fh, '-|', 'cat Lenna50.jpg' or die;
binmode $fh;
while ( sysread $fh , my $chunk , 1024 ) { $raw .= $chunk }
close $fh;
my $enable = $Imager::formats{"jpeg"}; # some kind of tie ?
my $IO = Imager::io_new_buffer $raw or die;
my $im = Imager::File::JPEG::i_readjpeg_wiol $IO or die;
open my $fh2, '>', 'output.ppm' or die;
binmode $fh2;
my $IO2 = Imager::io_new_fd(fileno $fh2);
Imager::i_writeppm_wiol $im, $IO2 ;
close $fh2;
undef($im);</lang>
{{out}}
<pre>file output.ppm
output.ppm: Netpbm PPM "rawbits" image data, size = 512 x 512
magick identify output.ppm
output.ppm PPM 512x512 512x512+0+0 8-bit sRGB 786464B 0.000u 0:00.014</pre>
=={{header|Phix}}==
|