Skip to main content

Default template for PDM package

Project description

Buy Me A Coffee

PicFix

PicFix is a command-line tool for quick and easy image manipulation. It provides simple yet powerful commands to resize, convert, and optimize images.

Features

  • Resize images to specified dimensions
  • Convert images between different formats
  • Optimize images to reduce file size
  • Support for multiple input files
  • Logging for operation tracking and debugging

Supported Image Formats

PicFix supports a wide range of image formats for both input and output:

  • JPEG (.jpg, .jpeg)
  • PNG (.png)
  • WebP (.webp)
  • GIF (.gif)
  • BMP (.bmp)
  • TIFF (.tiff, .tif)

Note: The actual support may vary depending on your system's Pillow installation. Some formats may be read-only or write-only. Optimization is currently focused on JPEG and PNG formats.

Installation

To install PicFix, follow these steps:

  1. Clone the repository:
git clone https://github.com/cruzancaramele/picfix.git
cd picfix
  1. Install dependencies using PDM:
pdm install

Usage

PicFix provides three main commands: resize, convert, and optimize.

To see the version of PicFix:

pdm run picfix --version

For general help:

pdm run picfix --help

Resize Command

Resize one or more images to specified dimensions:

pdm run picfix resize -i <input_file> -o <output_directory> --width <width> --height <height>

Example:

pdm run picfix resize -i image.jpg -o resized_images --width 800 --height 600

Convert Command

Convert one or more images to a specified format:

pdm run picfix convert -i <input_file> -o <output> [--format <format>]

The convert command is flexible and can handle various use cases:

  1. Convert a single file to a specific format:
pdm run picfix convert -i input.png -o output.jpg

This will convert input.png to output.jpg in JPEG format.

  1. Convert a file to a specific format, specifying the format explicitly:
pdm run picfix convert -i input.png -o output --format jpeg

This will convert input.png to output.jpeg in JPEG format.

  1. Convert multiple files to a specific format:
pdm run picfix convert -i image1.png -i image2.jpg -o output_dir --format webp

This will convert both image1.png and image2.jpg to WebP format and save them in the output_dir directory.

  1. Convert a file and save it in a specific directory:
pdm run picfix convert -i input.png -o output_dir/ --format jpeg

This will convert input.png to JPEG format and save it as input.jpeg in the output_dir directory.

The --format option supports the following formats: JPEG, PNG, WebP, GIF, BMP, and TIFF. If not specified, the format will be determined from the output filename extension.

Note: When converting multiple files, the output must be a directory.

[Rest of the README content...]

Optimize Command

Optimize one or more images to reduce file size:

pdm run picfix optimize -i <input_file> -o <output_directory> [options]

Options:

  • -q, --quality: Set the quality for lossy compression (1-100, for JPEG)
  • -t, --target-size: Set a target file size in KB
  • -s, --strip-metadata: Remove metadata from the image

Example:

pdm run picfix optimize -i image.jpg -o optimized_images -q 85 -t 100 -s

This command will optimize image.jpg, aiming for a quality of 85 and a target size of 100KB, while also stripping metadata.

Image Optimization

The optimize command uses different strategies for JPEG and PNG files:

  • For JPEG: It adjusts the compression quality to meet the target size or reduce file size by at least 20%.
  • For PNG: It uses color quantization, trying different color palette sizes to find the best balance between file size and image quality.

Note: PNG optimization might be limited for images with transparency.

Development

PicFix uses PDM for dependency management. To set up the development environment:

  1. Install PDM if you haven't already:
pdm install
  1. Install development dependencies:
pdm install -d
  1. Run tests:
pdm run pytest

Project Structure

  • src/picfix/: Main package
  • commands/: Command implementations
  • img_processors/: Image processing logic
  • models/: Data models for commands
  • tests/: Test files (to be implemented)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

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

picfix-0.1.2.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

picfix-0.1.2-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file picfix-0.1.2.tar.gz.

File metadata

  • Download URL: picfix-0.1.2.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.17.1 CPython/3.12.4 Darwin/23.5.0

File hashes

Hashes for picfix-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c4147f31a68747904ef79ea9c662fe2eaa2a5adc2a7e88df6f4fa55126745795
MD5 30482f79fd680cab30875603075f9f09
BLAKE2b-256 36402b5d18b79082a6514009a362c55cc943cb2b5cccae766a223028d896f660

See more details on using hashes here.

File details

Details for the file picfix-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: picfix-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.17.1 CPython/3.12.4 Darwin/23.5.0

File hashes

Hashes for picfix-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0a5bc341ca94e183c84b33ebd4493b18383c174cdc10800d0507a82daccb3bed
MD5 dd43a48dba6001a6578f0e8c7e90e31f
BLAKE2b-256 f3808d82dad76d78f6ad79ed32d8bce79d42c09a02945a09b69a9003fd695d93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page