With this basic information, let's build a simple image file converter. This utility will batch-process image files and save them in a user-specified file format.
To get started, download the file ImageFileConverter.py
from the Packt website, www.packtpub.com. This file can be run from the command line as:
python ImageConverter.py [arguments]
Here, [arguments]
are:
--input_dir
: The directory path where the image files are located.--input_format
: The format of the image files to be converted. For example,jpg
.--output_dir
: The location where you want to save the converted images.--output_format
: The output image format. For example,jpg
,png
,bmp,
and so on.
The following screenshot shows the image conversion utility in action on Windows XP, that is, running image converter from the command line.
Here, it will batch-process all the .jpg
images within C:\PythonTest\images
and save them in png
format in the directory C:\PythonTest\images\OUTPUT_IMAGES
.
The...