Shell stdin/stdout

J. Landman Gay jacque at hyperactivesw.com
Sun Aug 11 23:07:23 EDT 2013


I've been playing around with pngquant to optimize some pngs. It uses 
this syntax:

    usage:  pngquant [options] [ncolors] [pngfile [pngfile ...]]

I'm able to use it both in Terminal and with LiveCode's shell command. I 
pass it some options and a file name, and it makes a new optimized png 
file in the same folder.

Now I want to do it via stdin/stdout. I want to pass it a file name on 
disk (or an image in a stack) and get back the binary data for the new 
image. The man page says this:

"The output filename is the same as the input name except that
it ends in "-fs8.png", "-or8.png" or your custom extension (unless the
input is stdin, in which case the quantized image will go to stdout)."

How would I use stdin/stdout? I tried passing it the binary data of an 
image in a stack but I get back "command not found." If I pass it a file 
path on disk it always writes a new file.

Here's an example of a file-based command that works:

    put <pathToPngquant> && "16" && <pathToImage> into tCmd
    get shell(tCmd)

The "it" variable is empty, and the new file appears on disk. I want to 
do this:

    put <pathToPngquant> && "16" && (the text of img 1) into tCmd
    get shell(tCmd) -- get binary data back

Or, if not the text of img 1, using the binary data of an image on disk 
would be okay too.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list