Creating Thumbnails: dcraw and ImageMagick in a Batch File (2)

Usage for RAW files.

Batch File

Written by Matthias Vonken. You have to fit the paths to dcraw.exe and convert.exe.

@echo off
set IMAGE=%1
set MAX_DIM=%2

rem Extracting image suffix
for %%i in (%IMAGE%) DO set THUMB_SUFFIX=%%~xi

rem Deciding whether RAW or not
if /I "%THUMB_SUFFIX%" ==".gif" GOTO OTHER
if /I "%THUMB_SUFFIX%" ==".jpg" GOTO OTHER
if /I "%THUMB_SUFFIX%" ==".tif" GOTO OTHER

"C:\dcraw\dcraw.exe" -e -c %IMAGE% | "C:\Program Files\ImageMagick-6.6.9-Q16\convert.exe" - -thumbnail %MAX_DIM%x%MAX_DIM% -auto-orient jpg:-
goto END

:OTHER
"C:\Program Files\ImageMagick-6.6.9-Q16\convert.exe" %IMAGE% -thumbnail %MAX_DIM%x%MAX_DIM% -auto-orient jpg:-

:END

Author: Elmar Baumann
Write e-Mail
Status of this document: 2011-05-05