Skip to main content

PhoToRectify

Notice: Only tested for Hasselblad L1D-20c and Pentax K-1 with HD Pentax-D FA 28-105mm f/3.5-5.6 ED DC WR.

Undistort images with the Lensfun library and OpenCV. Multiprocessing is supported to speed up the rectification.

  • Allowed input file formats: BMP, JPEG, JPEG 2000, PNG, PIF, SUN RASTERS, TIFF
  • Output file formats: JPEG, TIFF
  • Currently supported and used compressions:
    • JPEG with Quality 97
    • TIFF with JPEG-Compression
  • Custom meta data (optional arguments, use quotes if they contain spaces)

Installation

Installation into a virtual environment is recommended, because PhoToRectify depends on some other packages.

Install with: pip install photorectify
Update with: pip install --upgrade photorectify

Requirements

  • Python 3.7+

  • exiftool 10.38+ (older versions not tested; install it with your distribution’s package manager)

  • PyExifTool has been modified and is shipped with photorectify’s source code (removed -n optional argument for proper lens detection with Lensfun + added method copy_tags())

  • For development: poetry (do not skip the installation of the development dependencies!)

Alternative remapping method for undistort()

Instead of using Pillow, you can also use OpenCV for remapping.

self.img_bgr_undist = lensfunpy.util.remap(
    self.img_blob_bgr,
    undistorted_coords)

Examples

Rectify one photo in a directory (rectifed photo are stored in the same directory as the input file):
photorectify Sampledata/DJI_0051.JPG

Rectify all photos in a directory:
photorectify Sampledata/

Rectify into a custom output directory:
photorectify Sampledata/ -o Sampledata/Rectified

Append custom suffix to rectified photos (automatically adds an underscore):
photorectify Sampledata/ -s rect

Specify meta data if photo hasn’t any EXIF tags:

photorectify Sampledata/DJI_0051.JPG \
    --model L1D-20c \
    --make Hasselblad \
    --FLength 10.26 \
    --FNumber 4.5

Get version:
photorectify --version

Development

More cameras and lenses can be supported by adding them to lensfun-db.xml. See the Lensfun database.

Running tests:
poetry run pytest -q tests/test_rectification.py

Contribution

To help improving this python package, open an issue or create a merge request.

Metadata

Release files for photorectify 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for photorectify 1.1.2
File Size Uploaded
PhoToRectify-1.1.2.tar.gz 13.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for photorectify 1.1.2
File Interpreter ABI Platform
PhoToRectify-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 27.5 kB

Release files / PhoToRectify-1.1.2.tar.gz

Download URL PhoToRectify-1.1.2.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
34a46751faee6ce032ca993a0025e6c17d3a84aed664fe2b17783e80bcd3f410
BLAKE2b-256 checksum
How to use checksums
592bbf7fcf1eaa5bd202242bde9b6f34213dc6e6cfbecff5f5c4a95c3a4bddbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.8.9 Windows/10

Release files / PhoToRectify-1.1.2-py3-none-any.whl

Download URL PhoToRectify-1.1.2-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d080635428aad21104eb1abc10d4133cabc42f80b7bb652d5bf158c0eec0e594
BLAKE2b-256 checksum
How to use checksums
89d7f38d262ad159a8856f6dd1b6ba79710647d4cc45f35d6f621ad5c93a0919
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.8.9 Windows/10

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page