-
Notifications
You must be signed in to change notification settings - Fork 0
cildatathumbnailcreator.py
Chris Churas edited this page Oct 30, 2018
·
2 revisions
This script generates thumbnail images of files with suffix specified by --suffix
flag in sizes specified by --sizes
flag.
Output when passing --help on command line:
usage: cildatathumbnailcreator.py [-h]
[--log {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
[--sizes SIZES] [--suffix SUFFIX]
[--overwrite] [--version]
downloaddir destdir
Version 0.2.0
This script generates thumbnail images of
files with suffix specified by --suffix flag
in sizes specified by --sizes flag.
This script requires two arguments in this order:
<INPUT> <DEST>
<INPUT> should be an input directory
or image file.
<DEST> is destination directory that will be
created if it does not already exist.
What data is converted depends on the
the layout of data in the <INPUT> argument.
If the <INPUT> is an image file:
A thumbnail for each size in --sizes flag will
be created under <DEST/<INPUT -minus suffix> directory
with file name convention described below in
'Output thumbnail naming convention' section below.
If the <INPUT> is a directory:
If within the directory an images/ and/or videos/
directories are found then the following occurs
for each of those directories:
1) A images and/or videos subdirectory is created
under <DEST> directory.
2) The script examines the images and/or videos
directories and looks for every directory named with
a number ### ie 1235.
3) Thumbnails are created for any image file within those
numeric directories if the image file is named with
same numeric name as parent directory with suffix
matching --suffix flag value. The resulting thumbnails
are put into the <DEST> directory under
a directory with same numeric ### name:
<DEST>/####/
Example:
If <INPUT> has an images/ directory and
within is a directory named 12345 and it contains
the image file 12345.jpg, the following thumbnails
would be created:
<DEST>/12345/
12345_thumbnailx88.jpg
12345_thumbnailx140.jpg
12345_thumbnailx220.jpg
12345_thumbnailx512.jpg
In addition if the <INPUT> is a directory any
directories immediately under the <INPUT> directory
that are numeric ie 12345 will also have thumbnails
generated as described above for images and videos
sub directories.
WARNING: File name conflict can occur if the same
directory exists in <DEST> and/or images/,
videos/ directories. This would result in
thumbnail files being overwritten.
Output thumbnail naming convention:
<ORIG FILE -SUFFIX>_thumbnailx<SIZE>.<SUFFIX>
<ORIG FILE -SUFFIX> -- original file name minus suffix
<SIZE> -- size of thumbnail in pixels ie 88.
<SUFFIX> -- suffix specified with --suffix flag.
Example:
For input of 12345.jpg would thumbnail named
12345_thumbnailx512.jpg
For more information visit:
https://github.com/CRBS/cildata_util/wiki
positional arguments:
downloaddir Directory where images and videos reside
destdir Directory where thumbnails will be saved
optional arguments:
-h, --help show this help message and exit
--log {DEBUG,INFO,WARNING,ERROR,CRITICAL}
Set the logging level (default WARNING)
--sizes SIZES Comma delimited list of thumbnail sizesin pixels. The
thumbnail will maintain aspect ratio and be padded for
non square images with black. (default 88,140,220,512)
--suffix SUFFIX Suffix for images. (default .jpg)
--overwrite NOT IMPLEMENTED. If set overwrites any existing
thumbnails. Otherwise existing thumbnails are skipped.
--version show program's version number and exit