Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
val useOSConvert = fn ppm =>
|
||||
let
|
||||
val img = String.translate (fn #"\"" => "\\\""|n=>str n ) ppm ;
|
||||
val app = " convert - jpeg:- "
|
||||
val fname = "/tmp/fConv" ^ (String.extract (Time.toString (Posix.ProcEnv.time()),7,NONE) );
|
||||
val shellCommand = " echo \"" ^ img ^ "\" | " ^ app ;
|
||||
val me = ( Posix.FileSys.mkfifo
|
||||
(fname,
|
||||
Posix.FileSys.S.flags [ Posix.FileSys.S.irusr,Posix.FileSys.S.iwusr ]
|
||||
) ;
|
||||
Posix.Process.fork ()
|
||||
) ;
|
||||
in
|
||||
if (Option.isSome me) then
|
||||
let
|
||||
val fin =BinIO.openIn fname
|
||||
in
|
||||
( Posix.Process.sleep (Time.fromReal 0.1) ;
|
||||
BinIO.inputAll fin before
|
||||
(BinIO.closeIn fin ; OS.FileSys.remove fname )
|
||||
)
|
||||
end
|
||||
else
|
||||
( OS.Process.system ( shellCommand ^ " > " ^ fname ^ " 2>&1 " ) ;
|
||||
Word8Vector.fromList [] before OS.Process.exit OS.Process.success
|
||||
)
|
||||
end;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
useOSConvert "P3 3 2 255 255 0 0 0 255 0 0 0 255 255 255 0 255 255 255 0 0 0" ;
|
||||
val it =
|
||||
fromList[0wxFF, 0wxD8, 0wxFF, 0wxE0, 0wx0, 0wx10, 0wx4A, 0wx46, 0wx49,
|
||||
0wx46, ...]: BinIO.vector
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
val demo = fn () =>
|
||||
let
|
||||
val useOSConvert = fn ppmf =>
|
||||
let
|
||||
val appopt = ("/usr/local/bin/convert", ["convert","-", "/tmp/out.jpeg"])
|
||||
val p = Posix.IO.pipe () ;
|
||||
val me = Posix.Process.fork ()
|
||||
in
|
||||
case me of SOME cpd =>
|
||||
( Posix.IO.close (#outfd p);
|
||||
Posix.IO.dup2 {old=(#infd p), new= Posix.FileSys.stdin } ;
|
||||
Posix.IO.close (#infd p);
|
||||
Posix.Process.exec appopt
|
||||
)
|
||||
| _ =>
|
||||
( Posix.IO.close (#infd p);
|
||||
ppmf (#outfd p) ;
|
||||
Posix.IO.close (#outfd p) ;
|
||||
OS.Process.exit OS.Process.success
|
||||
)
|
||||
end;
|
||||
|
||||
fun output_ppm fd = (* placeholder for the ppm/bitmap functionality *)
|
||||
Posix.IO.writeVec ( fd ,
|
||||
Word8VectorSlice.full ( Byte.stringToBytes
|
||||
"P3 3 2 255 255 0 0 0 255 0 0 0 255 255 255 0 255 255 255 0 0 0 " )
|
||||
)
|
||||
|
||||
in
|
||||
|
||||
useOSConvert output_ppm
|
||||
|
||||
end ;
|
||||
Loading…
Add table
Add a link
Reference in a new issue