Page 1 of 1

Pyramid Tif for all images in subdirectory

Posted: 2010-12-03T11:50:47-07:00
by maxnerpg
I would like to batch convert all images in a subdirectory to create pyramid tifs. My windows dos .bat file is:

@ECHO OFF
convert.exe c:\image\jpg\200311032.jpg -define tiff:tile-geometry=256x256 -compress jpeg ptif:c:\image\ptif\200311032.tif
PAUSE

I want to do something like

@ECHO OFF
convert.exe c:\image\jpg\*.jpg -define tiff:tile-geometry=256x256 -compress jpeg ptif:c:\image\ptif\*.tif
PAUSE

But it errors on recreating the file name for *.tif.

Re: Pyramid Tif for all images in subdirectory

Posted: 2010-12-03T11:57:33-07:00
by GreenKoopa
The wildcards * and ? expand to a list of files, but the output files don't yet exist and so this doesn't make sense. Even if they did exist, ImageMagick couldn't match the inputs to the outputs. Fortunately there is a solution. See:
http://www.imagemagick.org/Usage/files/#save_escapes

Re: Pyramid Tif for all images in subdirectory

Posted: 2010-12-03T12:26:02-07:00
by maxnerpg
Here is the answer:

::Turn of displaying the code on the screen

@echo off

:: Read all the jpg images from the directory, convert them to 256x256 tiles, compress jpeg and create the pyramid tif in another directory

for %%f in (c:\image\jpg\*.jpg) do ( convert "%%f" -define tiff:tile-geometry=256x256 -compress jpeg ptif:c:\image\ptif\%%~nf.tif )

PAUSE

Found the basis for this on http://www.rubblewebs.co.uk/imagemagick/batch.php

I'm looking at pyramid tiffs because of: http://iipimage.sourceforge.net/

Re: Pyramid Tif for all images in subdirectory

Posted: 2010-12-03T12:46:40-07:00
by GreenKoopa
A great solution!

Windows users, read more about loops and extracting part of a file name:
http://technet.microsoft.com/en-us/libr ... 90909.aspx

This is also covered in the ImageMagick Usage Examples:
http://www.imagemagick.org/Usage/windows/#filenames