Processing of multi-page TIFF files.

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, helmut, xnview

SAMSAM
Posts: 28
Joined: Sun Sep 15, 2019 5:14 pm

Processing of multi-page TIFF files.

Post by SAMSAM »

Good day to all!
Please tell me if it is possible to use the converter utility to process and save a multi-page TIF file without having to parse it page by page? Any attempt I make to process a multi-page TIFF results in a single-page TIFF, and only pagination produces the result. :?
cday
XnThusiast
Posts: 4132
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Processing of multi-page TIFF files.

Post by cday »

SAMSAM wrote: Sat Mar 13, 2021 6:13 pm Please tell me if it is possible to use the converter utility to process and save a multi-page TIFF file without having to parse it page by page? Any attempt I make to process a multi-page TIFF results in a single-page TIFF, and only pagination produces the result. :?
You want to convert a multi-page TIFF directly to a multi-page TIFF, presumably performing some operation(s) on each page?

I'm not sure what you mean exactly by parsing each page and by pagination, but perhaps that doesn't matter.

You presumably have the NConvert help file?
SAMSAM
Posts: 28
Joined: Sun Sep 15, 2019 5:14 pm

Re: Processing of multi-page TIFF files.

Post by SAMSAM »

There are a number of tasks, such as resaving the tif with a different type of compression or deleting metadata. At the moment, I first split a multi-page file, then process it page by page, and then assemble it into a multi-page file. Is it possible to do this without pagination. If yes, please write an example for nconvert.
cday
XnThusiast
Posts: 4132
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Processing of multi-page TIFF files.

Post by cday »

I knew it is possible to convert multipage to multi-page because I tested various combinations of multi-TIFF to multi-TIFF and multi-PDF to multi-PDF some years ago, and after some quick tests the following outline code works for me:

Code: Select all

nconvert -out tiff -multi -o Output.tif Input.tif

You will probably need to add suitable compression for your case, and can find that and filename options from the help file.

Note that if you are viewing the output multi-page file in XnView MP, you step between the pages using the small toolbar arrows, not the usual larger ones.

Any problems post again.
SAMSAM
Posts: 28
Joined: Sun Sep 15, 2019 5:14 pm

Re: Processing of multi-page TIFF files.

Post by SAMSAM »

Thank you, everything worked fine! :) Now I have dealt with this issue. My mistake was putting the "-multi" command before the "-out tiff" command.
cday
XnThusiast
Posts: 4132
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Processing of multi-page TIFF files.

Post by cday »

SAMSAM wrote: Sat Mar 13, 2021 7:35 pm Thank you, everything worked fine! :) Now I have dealt with this issue. My mistake was putting the "-multi" command before the "-out tiff" command.
In general, the order of options doesn't seem to matter much -- there is no documentation on that point that I know of except that the input term must be the last right-most term -- but in the above case the order does matter, I think.
SAMSAM
Posts: 28
Joined: Sun Sep 15, 2019 5:14 pm

Re: Processing of multi-page TIFF files.

Post by SAMSAM »

Now I checked it on an array of multi-page tif files. And it turned out that the proposed set of commands works only on a single multi-page file. When you try to process an array of multiple multi-page files, the result is combined into a single file. Here is my example (for totalcommander)
-rmeta -out tiff -multi -c 2 -c_bw 7 -o New\%%.tif %S
What is the error?
cday
XnThusiast
Posts: 4132
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Processing of multi-page TIFF files.

Post by cday »

I'm not familiar with Total Commander, but if you need to batch process multi-page files in Windows using CMD, I would think you would probably need to place the above code for a single input file within a For loop.

I am an inexperienced command line user and provide support for NConvert because no-one else does except Pierre, who has very limited time, and while I have managed to use For loops, I'm afraid I can't provide support for that.
SAMSAM
Posts: 28
Joined: Sun Sep 15, 2019 5:14 pm

Re: Processing of multi-page TIFF files.

Post by SAMSAM »

OK, I'll try to do this via the FOR command in CMD. Thanks for the idea.
cday
XnThusiast
Posts: 4132
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Processing of multi-page TIFF files.

Post by cday »

There is a good chance that you have more experience with For loops than I do, but looking through some of my old scripts the following code (adapted for multi-page TIFF output rather than PDF output) may be relevant if you don't have a solution yet:

Code: Select all

For %%A In ("C:\Y\*.tif") Do nconvert -out tiff -multi -o "C:\Y\%%.tif" "%%A" 

Absolutely no warranty!

Edit: The fact that in the above version both input and output files are TIFFs probably requires a tweak, such as putting the output files in a different directory to avoid the risk of creating an infinite loop, or a suitable choice of input filenames.
cday
XnThusiast
Posts: 4132
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Processing of multi-page TIFF files.

Post by cday »

The following code seems to work for me in a quick test:

Code: Select all

For %%A In ("C:\X\*.tif") Do nconvert -out tiff -multi -o "C:\Y\%%.tif" "%%A" 

Derived quickly from a previous test, output filenames as input filenames, required actions and compression to be added.
SAMSAM
Posts: 28
Joined: Sun Sep 15, 2019 5:14 pm

Re: Processing of multi-page TIFF files.

Post by SAMSAM »

Thank you, everything works very well! :D