Convert multi-page tiff from STDIN pipe

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
.thud

Convert multi-page tiff from STDIN pipe

Post by .thud »

Goal: Convert a multi-page tiff file into several png files when reading from STDIN.

Problem: When you have a file as input you can index frames e.g. using
convert "infile.tif" b%03d.tif (http://www.imagemagick.org/Usage/formats/#tiff)
but this syntax cannot be used when piping input from STDIN.
For example, I tried "tiff[0]:-" as STDIN placeholder and "png:-" as STDOUT placeholder
which does not work. I did not find documentation on the placeholder syntax.

I do not want to save it on disk if this can be avoided!
Big thanks for your ideas!
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Convert multi-page tiff from STDIN pipe

Post by Drarakel »

If you want to convert a multipage TIF from stdin into separate PNGs, you should be able to use something like that:
... convert - page%3d.png (for three digits)
If you want to pick only a certain page (or a range of pages), use something like this:
... convert -[0] page0.png

Some documentation:
http://www.imagemagick.org/Usage/files/#read_mods
http://www.imagemagick.org/Usage/files/#adjoin

Works for me at least (IM v6.6.3-0, Windows).



But while testing it, I noticed some irregularities. Seems that if one writes to stdout, the pixel cache files for some formats doesn't get deleted. Example (look in your temporary directory):
convert rose: TIFF:- | identify -
And, on my system, writing a image sequence to stdout can result in a crash:
convert rose: logo: BMP:- | identify -
Can someone else reproduce it?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert multi-page tiff from STDIN pipe

Post by snibgo »

Code: Select all

But while testing it, I noticed some irregularities. Seems that if one writes to stdout, the pixel cache files for some formats doesn't get deleted. Example (look in your temporary directory):
convert rose: TIFF:- | identify -
And, on my system, writing a image sequence to stdout can result in a crash:
convert rose: logo: BMP:- | identify -
Can someone else reproduce it?
Confirmed on Windows 7, IM 6.6.0-8 and 6.6.3-0.
snibgo's IM pages: im.snibgo.com
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Convert multi-page tiff from STDIN pipe

Post by Drarakel »

snibgo wrote:Confirmed on Windows 7, IM 6.6.0-8 and 6.6.3-0.
Thanks! These issues are probably not very important, but I created a thread in the bugs forum.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Convert multi-page tiff from STDIN pipe

Post by anthony »

Drarakel wrote:But while testing it, I noticed some irregularities. Seems that if one writes to stdout, the pixel cache files for some formats doesn't get deleted. Example (look in your temporary directory):
convert rose: TIFF:- | identify -
And, on my system, writing a image sequence to stdout can result in a crash:
convert rose: logo: BMP:- | identify -
Can someone else reproduce it?
such a thing should be reported as a bug. We have had reports of tmp junk being left behind, but nothing about the commands which could caused the junk tmp files.

Code: Select all

convert rose: TIFF:- | identify -
No junk /tmp files were left, and I get a good identify.

Code: Select all

convert rose: logo: BMP:- | identify -
Produces an error (convert: unable to write blob `-') so it may be the BMP coder can not handle stdout. It does leave 2 /tmp junk files.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Convert multi-page tiff from STDIN pipe

Post by Drarakel »

Thanks for testing. The replies are in the thread in the bugs forum.
Post Reply