Skip to main content

photo-restorer

PyPI version Python versions License: MIT

photo_restorer is a local-first Python library for restoring and optimizing real photographs with a compact public API. It keeps the main processing flow on the local machine, uses weights under models/ by default, and exposes high-level operations for full optimization, face restoration, color correction, and perceptual pre-downscaling.

Supported operations

  • Single-image optimization from local path, base64, or data URL
  • Batch optimization for multiple local files
  • Optional face restoration with GFPGAN
  • Final color correction for real photographs
  • Optional perceptual pre-downscale before full optimization
  • Local model management rooted at models/

Requirements

  • Python 3.12 or higher
  • Local runtime dependencies installed through pip
  • Enough disk space for model weights under models/

Install

pip install photo-restorer

Checking the version

import photo_restorer

print(photo_restorer.__version__)

Configuration

The main workflow does not require API keys or remote service credentials.

Configuration is resolved lazily in this order:

  1. Explicit parameters passed to PhotoRestorer(...) or to each function call
  2. Environment variables from the current process

photo_restorer does not auto-load .env files.

Providers and environment variables

Item Type Notes
Local models under models/ Runtime backend Uses local weights for Real-ESRGAN, GFPGAN, and related helpers
Remote services Provider Not used by the main public API
PHOTO_RESTORER_MODELS_ROOT Env var Overrides the local models root
PHOTO_RESTORER_USE_CPU Env var Forces CPU execution when truthy
PHOTO_RESTORER_FACE_RESTORATION Env var Enables or disables the face pass
PHOTO_RESTORER_PRE_DOWNSCALE Env var Enables perceptual pre-downscaling
PHOTO_RESTORER_OUTPUT_SUFFIX Env var Changes the default batch output suffix

See docs/configuration.md for the full configuration guide.

Quickstart

Optimize a single image

from photo_restorer import optimize_image

result_base64 = optimize_image(
    "examples/photo.jpg",
    pre_downscale=True,
)

Optimize multiple local images

from photo_restorer import optimize_images

optimize_images(
    ["examples/photo-1.jpg", "examples/photo-2.png"],
    suffix="_restored",
)

Restore faces only

from photo_restorer import restore_faces

restored_face_base64 = restore_faces(
    "examples/portrait.jpg",
    face_blend_weight=0.45,
)

Correct colors only

from photo_restorer import correct_colors

corrected_base64 = correct_colors("examples/faded-photo.jpg")

Apply perceptual pre-downscale only

from photo_restorer import pre_downscale_image

reduced_base64 = pre_downscale_image("examples/oversampled.png")

Reuse a stateful client

from photo_restorer import PhotoRestorer

client = PhotoRestorer(
    models_root="models",
    use_cpu=True,
)

optimized_base64 = client.optimize_image("examples/photo.jpg")
client.optimize_images(["examples/photo-1.jpg", "examples/photo-2.jpg"])

Public API

Module Members Purpose
photo_restorer PhotoRestorer, optimize_image, optimize_images, restore_faces, correct_colors, pre_downscale_image Main high-level API
photo_restorer.client PhotoRestorer, optimize_image, optimize_images, restore_faces, correct_colors, pre_downscale_image Stateful client and convenience helpers
photo_restorer.models PhotoRestorerSettings, ImageOptimizationOptions, BatchOptimizationOptions, ModelArtifact Public Pydantic models
photo_restorer.exceptions PhotoRestorerError, ConfigurationError, ImageSourceError, InputImageNotFoundError, SameOutputDirectoryError, ModelProvisioningError, ProcessingError Public exception hierarchy

Error handling

All public exceptions inherit from PhotoRestorerError.

from photo_restorer import optimize_image
from photo_restorer.exceptions import PhotoRestorerError

try:
    payload = optimize_image("examples/photo.jpg")
except PhotoRestorerError as exc:
    print(f"Restoration failed: {exc}")

See docs/errors.md for the complete exception hierarchy and handling guidance.

Additional docs

Contributing

Development workflow, editable installs, linting, testing, and release steps live in CONTRIBUTING.md.

Metadata

Release files for photo-restorer 0.1.1

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

Source distribution (sdist)

Source distribution for photo-restorer 0.1.1
File Size Uploaded Provenance Actions
photo_restorer-0.1.1.tar.gz 46.1 kB Without provenance Details for photo_restorer-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for photo-restorer 0.1.1
File Interpreter ABI Platform Actions
photo_restorer-0.1.1-py3-none-any.whl Python 3 none any Details for photo_restorer-0.1.1-py3-none-any.whl

Total release size: 104.8 kB

Release files / photo_restorer-0.1.1.tar.gz

Download URL photo_restorer-0.1.1.tar.gz
Size 46.1 kB
Tags Source
SHA-256 checksum
How to use checksums
29f97d8a9b0dcdaee26ea39bb44173c458aa7b6946a086f13981dfd70a360541
BLAKE2b-256 checksum
How to use checksums
da509ac967762d69adeeaa2fe72094174705ef6e3953655a479e829fc0918a45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / photo_restorer-0.1.1-py3-none-any.whl

Download URL photo_restorer-0.1.1-py3-none-any.whl
Size 58.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56726a6f9f71b1bfbcec6ea8dffcb237c854a29948f59ae116f257b7f63f090b
BLAKE2b-256 checksum
How to use checksums
7c9319c91f596e3f2d904d258dc7d84d70885deb31c8d92da268b4466935873a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Security for photo-restorer 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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