A utility to convert TIF images to PNG with optional resizing and renaming. Preserve quality of photos from apps like Adobe Lightroom while formatting files for social media sharing.
Project description
TIF to PNG Image Converter
Introduction
This Python script converts TIF images to PNG format. It allows for resizing the images to various predefined sizes (Original, 4K, 2K) and works either on a directory or individual files. It also allows for renaming the converted files based on a regex pattern extracted from the original file name.
Requirements
- Python 3.5+
- PIL (Pillow) library
Installation
Install the convert-tif-to-png tool via pip:
pip install convert-tif-to-png
Also, ensure you have the required Pillow library:
pip install Pillow
Usage
Command Line Options
Option | Description |
---|---|
--dir |
Path to directory containing TIF files to convert. |
--file |
Path to individual TIF file(s) to convert. |
--pattern |
Regex pattern to name converted files, extracted from the original file name. |
--size |
Resize images to one of the following sizes: original , 4k , 2k . |
--log |
Log output to file. Defaults to ./.log.txt |
Examples
To process a directory:
convert-tif-to-png --dir /path/to/directory --pattern 'some-regex-pattern' --size 4k
To process individual files:
convert-tif-to-png --file /path/to/file1.tif /path/to/file2.tif --pattern 'some-regex-pattern' --size 4k
Integration: MacOS Automator
Prerequisites
Before integrating this script into MacOS Automator, make sure you have the following prerequisites installed and configured:
-
pyenv
: A Python version management tool, used to set the Python version for the script.- Installation: Use Homebrew by running
brew install pyenv
in your terminal. - Setting up: Add
pyenv init
to your shell to enable shims and autocompletion. See official documentation for more details.
- Installation: Use Homebrew by running
-
Python Path: You'll need the full path to your Python interpreter.
- Finding Python Path: Run
which python
orwhich python3
in your terminal to get the full path.
- Finding Python Path: Run
Integration
To integrate this script into macOS Automator for automated file processing:
- Open Automator and create a new "Folder Action."
- Set the "Folder Action receives files and folders added to" to your desired directory.
- Set "Pass input" to "as arguments."
- Add a "Run Shell Script" action.
- Enter the full path to your Python interpreter and script, along with any command line arguments, like so:
/full/path/to/python3 -m convert-tif-to-png --size 4k --pattern 'some-regex-pattern' --file "$@"
Make sure you replace /full/path/to/python3
with the actual path on your system.
Any new TIF files added to the specified folder will automatically be converted to PNG.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for convert_tif_to_png-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8885d6d776222bd6f4d9ae12fd6eb01ec4733b27254835b905630a088543dfc5 |
|
MD5 | e0f9811926ff79384e8df829ae6e7eb8 |
|
BLAKE2b-256 | 26185d01922b51c762e3c9bdff92c4ebccc733a77c387847c1b913d948d73258 |