Skip to main content

epub-image-optimizer

GitHub Workflow Status PyPI PyPI - Python Version codecov DeepSource GitHub

Small Python CLI application to optimize images (including the cover) inside epub files. Perfect fit for optimizing LNs as they usually have a lot of images.

Installation

From PyPI directly:

pip install epub-image-optimizer

or

python3 -m pip install epub-image-optimizer

Usage

Usage: epub-image-optimizer [OPTIONS]

  EPUB Image Optimization tool

Options:
  --input-dir DIRECTORY           Input folder
  --output-dir DIRECTORY          Output folder
  --input-file FILE               Path to Epub Input file
  --max-image-resolution <INTEGER INTEGER>...
                                  Fit image resolution to this values, good
                                  for handling images with higher
                                  resolutions than your ebook-reader
  --tinify-api-key TEXT           Tinify api-key
  --only-cover                    Optimize only the cover image, ignoring all
                                  other images
  --workers INTEGER               Number of threaded workers to use, default
                                  is 'cpu count + 4'
  --keep-color                    If this flag is present images will preserve
                                  colors (not converted to BW)
  --log-level [INFO|DEBUG|WARN|ERROR]
                                  Set log level, default is 'INFO'
  --version                       Show current version
  --help                          Show this message and exit.

Examples

Convert all images to BW

epub-image-optimizer --input-file <my-epub>

Convert only cover to BW

epub-image-optimizer --input-file <my-epub> --only-cover

Optimize all images while keeping colors

epub-image-optimizer --input-file <my-epub> --keep-color

Note: At the moment this won't do anything as there is currently no optimization if not using Tinify.

Optimize all images using Tinify while keeping colors

epub-image-optimizer --input-file <my-epub> --keep-color --tinify-api-key <tinify-api-key>

Note: You can obtain your Tinify API Key here. Free tier is limited to 500 images/month.

Optimize and fit all images to custom resolution while keeping colors

epub-image-optimizer --input-dir <folder> --max-image-resolution 1680 1264 --tinify-api-key <tinify-api-key>

Note: This will optimize all epubs inside input-dir folder, used my Kobo Libra H2O screen size as example.

Development

Poetry is used for managing packages, dependencies and building the project.

Poetry can be installed by following the instructions. Afterwards you can use poetry install within the project folder to install all dependencies.

Metadata

Release files for epub-image-optimizer 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 epub-image-optimizer 1.1.2
File Size Uploaded Provenance Actions
epub_image_optimizer-1.1.2.tar.gz 9.1 kB Without provenance Details for epub_image_optimizer-1.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for epub-image-optimizer 1.1.2
File Interpreter ABI Platform Actions
epub_image_optimizer-1.1.2-py3-none-any.whl Python 3 none any Details for epub_image_optimizer-1.1.2-py3-none-any.whl

Total release size: 19.7 kB

Release files / epub_image_optimizer-1.1.2.tar.gz

Download URL epub_image_optimizer-1.1.2.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
aaecbb613d81740d71828b18ffddcee28d7507f1a1f7be1d0c3b2a1023eaf844
BLAKE2b-256 checksum
How to use checksums
9a2b13add8bddd27d205608d432af4c0b135d7a5b62146e2756cdc4580ff7180
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.8.18 Linux/6.5.0-1015-azure

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

Download URL epub_image_optimizer-1.1.2-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd032d69619886260c147fa39cb54319a0daf86f73187545ec9e60d15554261d
BLAKE2b-256 checksum
How to use checksums
417d43a14b494c376c1139f0fdc0d92d7ecbb2c56d1eb6a9225d9675739c1d77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.8.18 Linux/6.5.0-1015-azure

Security for epub-image-optimizer 1.1.2

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.

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