Pyramid Tif for all images in subdirectory

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
maxnerpg

Pyramid Tif for all images in subdirectory

Post 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.
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: Pyramid Tif for all images in subdirectory

Post 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
maxnerpg

Re: Pyramid Tif for all images in subdirectory

Post 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/
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: Pyramid Tif for all images in subdirectory

Post 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
Post Reply