An open API service indexing awesome lists of open source software.

https://github.com/werctfourth/python-border-autocrop2

Python script that crops borders from images v2
https://github.com/werctfourth/python-border-autocrop2

border crop image-processing libvips numba numpy python python3

Last synced: 6 months ago
JSON representation

Python script that crops borders from images v2

Awesome Lists containing this project

README

          

# Description

Python script for cropping clear borders of any color in images with some degree of noise tolerance.

More information is available in [previous version's readme](https://github.com/WerctFourth/python-border-autocrop)

# Differences

* Uses pyvips/libvips instead of Pillow for 16-bit/band and more format support
* Resizes images using Magic Kernel Sharp (a=6, v=7), Numpy + Numba resizer implementation
* Detects grayscale images saved as RGB and converts them back to grayscale (pyvips + numpy implementation)
* Saves 16-bit/band images after resizing (8-bit input images without resizing will be saved as 8-bit)
* Settings are saved in JSON with an ability to load custom settings files
* Can save and load job JSONs with custom settings for any file
* Saves to PNG (up to 16 bit), JXL (internal libvips, up to 16 bit), AVIF (still external, because internal ilbvips encoder doesn't support 8+ bit images; up to 12 bit)
* Option to ignore already vertically cropped space in horizontal crop

# Requirements
Python, [pyvips](https://pypi.org/project/pyvips/), [numpy](https://pypi.org/project/numpy/), [numba](https://pypi.org/project/numba/).

Optional: [pyvips-binary](https://pypi.org/project/pyvips-binary/) (Makes calls to libvips faster)

Tested on Python 3.13.1, pyvips 3.0.0, pyvips-binary 8.16.1, Numpy 2.2.5, Numba 0.61.2.

Requires external native [libvips library](https://github.com/libvips/libvips/releases).

# Resources

* [Magic Kernel official site](https://johncostella.com/magic/)
* [Magic Kernel Rust implementation](https://lib.rs/crates/magic-kernel)
* [pica JS resizer](https://github.com/nodeca/pica)