Bash piping

I am trying to pipe a jpg filename to the Image Magick display command. As in “cat myfile | display”. “myfile” contains a jpg filename. It returns the error “display: no decode delegate for this image format `/tmp/magick-XXPOGHGV’ @ error/constitute.c/ReadImage/532”. What am I doing wrong? If I invoke display with the jpg filename, it works just fine.

Thanks.

Reading

man display

I see that it should be invoked as

display [options] input-file

Thus the input file is a field in the command line. What you do is sending text to stdin of the display program, but nowhere is said that it does read anything from stdin.
I guess it will work when you do

 display $(cat myfile)

or even shorter

display $(<myfile)

On 2011-10-03 22:26, ionmich wrote:
>
> I am trying to pipe a jpg filename to the Image Magick display command.
> As in “cat myfile | display”. “myfile” contains a jpg filename. It
> returns the error “display: no decode delegate for this image format
> `/tmp/magick-XXPOGHGV’ @ error/constitute.c/ReadImage/532”. What am I
> doing wrong? If I invoke display with the jpg filename, it works just
> fine.

Not all programs accept input that way.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

On Mon, 03 Oct 2011 20:26:03 +0000, ionmich wrote:

> If I invoke display with the jpg filename, it works just fine.

Piping the name in from a file is not the same as invoking with the
filename.

What you’re doing is telling it the contents of the file are the image
data.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

Thank you very much. My incorrect assumption was that “display” accepts stdin. I will be more careful in future.