Bitmap/Read an image through a pipe: Difference between revisions

Line 311:
Based off the Julia program.
<lang Mathematica>Export["data/bitmapOutputTest.ppm",Import["data/bitmapOutputTest.jpg"]];</lang>
 
=={{header|Nim}}==
Using "jpegtopnm" from Netpbm suite. Input is a JPEG file and result (the PPM file) is sent to stdout. The procedure "readPPM" reads directly from the stream and build the image container.
 
<lang Nim>import bitmap
import osproc
import ppm_read
import streams
 
# Launch Netpbm "jpegtopnm".
# Input is taken from "input.jpeg" and result sent to stdout.
# We need to specify "options = {}" as by default stderr is redirected to stdout.
let p = startProcess("/usr/bin/jpegtopnm", args = ["input.jpeg"], options = {})
let stream = FileStream(p.outputStream())
let image = stream.readPPM()
echo image.w, " ", image.h
p.close()</lang>
 
=={{header|OCaml}}==
Anonymous user