Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Work Toolkit

An extensible collection of small automation tools. The first tool resizes images while preserving their aspect ratio by default.

Requirements

  • Python 3.12 or newer

Setup

python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e .

Resize an image

Provide one dimension to preserve the original aspect ratio:

work-toolkit resize input.jpg output.jpg --width 1200
work-toolkit resize input.png output.png --height 800

During development, use the equivalent module command without installing the console script:

PYTHONPATH=src python -m work_toolkit resize input.jpg output.jpg --width 1200

Provide both dimensions to fit the image inside that bounding box without cropping:

work-toolkit resize input.jpg output.jpg --width 1200 --height 800

If the output path already exists, the command asks whether to overwrite it. Enter y to overwrite, or enter a different output path when prompted. Leave the replacement path blank to cancel the command.

Resize a folder of images

Use --directory when input and output are folders. Every supported image inside the input folder (including subfolders) is resized and written below the output folder with the same filename and relative subfolder path.

work-toolkit resize photos resized-photos --width 1200 --directory

Convert an image to WebP

The output filename must end in .webp. By default, conversion uses lossy WebP with a quality level of 80.

work-toolkit convert-webp input.png output.webp
work-toolkit convert-webp input.jpg output.webp --quality 90
work-toolkit convert-webp input.png output.webp --lossless

Compress an image locally

compress uses Pillow locally; it never sends an image to TinyPNG or any other external service. PNG output uses adaptive palette optimization and maximum lossless compression. JPEG and WebP output use perceptual compression at a quality of 85 by default, which is intended to keep visual changes minimal.

work-toolkit compress input.png compressed.png
work-toolkit compress photo.jpg compressed.jpg --quality 90
work-toolkit compress photo.png compressed.webp --quality 85

To compress a folder of PNG, JPEG, and WebP files, use --directory. Files in subfolders are included and written under the output folder with the same relative path and filename.

work-toolkit compress photos compressed-photos --directory

For PNGs, --colors sets the maximum adaptive palette size (2–256; default: 256). Lower values can shrink files further but may introduce visible banding or color changes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages