ImageMagick: how to combine multiple TIFF files into one TIFF file in a directory?

I have 600 TIFF files in a directory, c: \ temp.

The file names are like:

001_1.tif,
001_2.tif,
001_3.tif

002_1.tif,
002_2.tif,
002_3.tif
....
....
200_1.tif,
200_2.tif,
200_3.tif

      

The combined files must be placed in the same directory and the files must be named:

1_merged.tif
2_merged.tif
.....
.....
200_merged.tif

      

I am looking for any separate command line / batch file to do this using the ImageMagick convert

/ command mogrify

or any other commands / tools.

Please note that the total time should not exceed 5 seconds.

+3


source to share


2 answers


Assuming you want to combine 600 one-page TIFFs into one multi-page TIFF (for each set of 3), this is as easy as:

 convert  001_*.tiff  1_merged.tiff
 convert  002_*.tiff  2_merged.tiff
 [....]
 convert  200_*.tiff  200_merged.tiff

      



Note that no one can guarantee any timing / performance criteria ... although we don't even know exactly how your input TIFFs are generated. (Are they 10000x10000 pixels or 20x20 pixels?), Are they color or grayscale ?, etc.)

This differs from Mark's answer because he assumed that you want to concatenate all the input files into a single page image, where the originals are interleaved with a larger page ...

+1


source


This should do it - I'll leave you to do error checking in case you haven't actually received all the images you suggest!

@ECHO OFF
setlocal EnableDelayedExpansion
FOR /L %%A IN (1,1,200) DO (
   set "formattedValue=000000%%A"
   set "x=!formattedValue:~-3!"
   convert !x!_*.tif +append !x!_merged.tif
   echo !x!
)

      

So if your images looks like this,

001_1.tif

enter image description here

001_2.tif

enter image description here



001_3.tif

enter image description here

you get it in merged_001.tif

enter image description here

If you change +append

to -append

then it merged_001.tif

will look like this:

enter image description here

If you delete it +append

altogether, you get 200 multi-page TIFs with 3 pages each - the same as Kurt's answer.

0


source







All Articles