Creating Thumbnails: Extracting embedded thumbnails with Exiv2

Batch File

Written by Matthias Vonken. You have to fit the path to exiv2.exe.

@echo off

set IMAGE=%1

rem Extracting image file name and remove suffix
for %%i in (""%IMAGE%"") do set THUMB_ROOT=%%~ni

rem Suffix of thumbnails created by Exiv2
set THUMB_SUFFIX=-preview1.jpg

rem Joining image filename and Exiv2 suffix
set THUMB="%THUMB_ROOT%%THUMB_SUFFIX%"

set TEMP_THUMBNAIL_FOLDER=%TMP%

rem Creating thumbnail
"C:\exiv2\exiv2.exe" -ep1 -l%TEMP_THUMBNAIL_FOLDER% %IMAGE%

rem Writing thumbnail into standard out
type "%TEMP_THUMBNAIL_FOLDER%"\%THUMB%

rem Deleting thumbnail
del "%TEMP_THUMBNAIL_FOLDER%"\%THUMB%

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