Skip to main content

Small application to optimize images (and cover) inside epub files

Project description

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.

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

epub_image_optimizer-1.1.2.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distribution

epub_image_optimizer-1.1.2-py3-none-any.whl (10.7 kB view hashes)

Uploaded Python 3

Supported by

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