Preview image from pipe

bashcommand linepreviewterminalx11

I have a command line utility, let's called as: produce_image. So i can do the following in the Terminal:

$ produce_image > some.jpg
$ open some.jpg #opens Preview.app

also, I have ImageMagick installed and Xqartz too, so I can do the following:

$ produce_image | display #the display is a command from ImageMagick suite

The above opens an X11 window with the image.

Is possible achieve such image-view as with display also with Preview.app? e.g. looking for something like:

$ produce_image | Preview.app #of course, this isn't working
$ produce_image | /Applications/Preview.app/Contents/MacOS/Preview #nor this

Is possible preview the image with Preview.app without using intermediate file?

Ps: of course, I can create a command such osxdisplay

tmpfile=$(mktemp /tmp/foobar.XXXXXX)
cat - > "$tmpfile"
open "$tmpfile"
rm -f $tmpfile

and use it as

produce_image | osxdisplay

But the merit of the question is about opening images from a shell pipe without intermediate files.

Best Answer

Try

produce_image | open -a Preview.app -f

(To be honest, I was quite surprised to learn that this works)