
Thread
1997.01.23 02:03 "Re: Reading from standard in", by Cristy
I'd suggest logic along the lines of copying data from stdin to a temp
This is what ImageMagick does (see below). Here is an example that accepts TIFF as STDIN and outputs a JPEG image:
cat image.tiff | convert - image.jpg
See
http://www.wizards.dupont.com/cristy/ImageMagick.html
for more details.
* * *
if ((image->file == stdin) || image->pipe)
{
FILE
*file;
int
c;
/*
Copy standard input or pipe to temporary file.
*/
TemporaryFilename(image_info->filename);
file=fopen(image_info->filename,WriteBinaryType);
if (file == (FILE *) NULL)
PrematureExit("Unable to write file",image);
c=fgetc(image->file);
while (c != EOF)
{
(void) putc(c,file);
c=fgetc(image->file);
}
(void) fclose(file);
(void) strcpy(image->filename,image_info->filename);
image->temporary=True;
}