Tifinity
A framework and helpful utilities for working with TIFF files.
Installation
pip install tifinity
How to use
Base usage: tifinity [-h] [-v] {module} [module-options]
- module selection:
-
module: One of the modules below - optional arguments:
-
-h, --help Show the help message and exit -v, --version Provide the version of this application
Tifinity is a framework encompassing a TIFF parser and a number of processing modules. Modules operate on TIFF files to delivery desired functionality, such as displaying tags or migrating the contents of the files. New modules can easily be created and added to the framework.
The base tifinity command (without any module specified) simply outputs the application's main help or the application's version - not hugely interesting!
To be of use for processing TIFFs, a module needs to be specified.
Modules
Available modules are:
migrate_rgb72
Migrates RGB TIFF images that are encoded as 24 bits-per-channel (i.e. 72 bits per pixel) to 36 bits-per-channel (96 bpi).
Usage: tifinity migrate_rgb72 [-h] [-o OUTPUT] path [path...]
- positional arguments:
-
path(s): a TIFF file or folder(s) containing TIFF files to migrate - optional arguments:
-
-h, --help Show the help message and exit -o OUTPUT CSV file to output statistics too
show_tags
Prints to console the IFD tags of the specified TIFF image.
Usage: tifinity show_tags [-h] file
- positional arguments:
-
file: the TIFF file whose IFD tags to show - optional arguments:
-
-h, --help Show the help message and exit
checksum
Calculates checksum values for the image data in each sub-image of the specified TIFF, as well as the full file.
Usage: tifinity checksum [-h] [-a {md5,sha256,sha512,sha3_256,sha3_512}] [--json] file
- positional arguments:
-
file: the TIFF file to generate checksum values for - optional arguments:
-
-a the checksum algorithm to use --json JSON formatted output; otherwise just prints to terminal -h, --help Show the help message and exit
compare
Compares two TIFF files against each other using the specified metric.
Usage: tifinity compare [-h] -m|--metric {checksum, checksum-images} [--json] tiff1 tiff2
- positional arguments:
-
tiff1: the first TIFF file to compare tiff2: the second TIFF file to compare - required arguments:
-
-m, --metric the metric to use to do the comparison. Currently supports full checksumming of the file, or checksumming of images (within a TIFF) only. - optional arguments:
-
--json JSON formatted output; otherwise just prints to terminal -h, --help Show the help message and exit
For example, to compare two TIFF files based on pixel image checksum comparison:
tifinity compare --metric checksum-images tiff1 tiff2
Development
Tifinity's folder structure is as below:
tifinity |--- actions |--- modules |--- parser |--- scripts |--- __main__.py
Modules are contained in the modules folder, supported by reusable cross-module scripted functions in the actions folder, and helper functions in the scripts folder.
The main TIFF parser is self contained in the parser folder.
Adding new Modules
An Abstract Base Module for all Modules is defined in modules/__init__.py.
This defines two abstract methods which all subclassing modules must implement:
- add_subparser(mainparser):
-
This adds a argparse subparser to the mainparser obtained from __main__.py. The subparser should define any command line arguments pertinent to it. It must also set a default 'func' key pointing to the process_cli function.
For example:
def add_subparser(self, mainparser): m_parser = mainparser.add_parser(self.cli_name) m_parser.set_defaults(func=self.process_cli) m_parser.add_argument("path", nargs="+", help="the TIFF file or folder(s) containing TIFFs to migrate.") m_parser.add_argument("-o", dest="output", help="the output folder to output the converted TIFF(s) to.")
- process_cli(args):
- This is the function called when a specific tifinity module is instigated.
License
Released under Apache version 2.0 license.
Contribute
- Fork the GitHub project
- Change the code and push into the forked project
- Submit a pull request