Skip to content

ISCC - EPUB Processing#

EPUB handling module.

epub_thumbnail(fp) #

Creat thumbnail from EPUB document cover image.

Parameters:

Name Type Description Default
fp

Filepath to EPUB document.

required

Returns:

Type Description

Thumbnail image as PIL Image object

epub_meta_embed(fp, meta) #

Embed metadata into a copy of the EPUB file.

Parameters:

Name Type Description Default
fp

Filepath to source EPUB file

required
meta IsccMeta

Metadata to embed into EPUB

required

Returns:

Type Description

Filepath to the new EPUB file with updated metadata

epub_cover(fp) #

Extract the cover image bytes from an EPUB file.

This function attempts to locate the cover image by first checking the metadata cover reference, then falling back to scanning for image files with 'cover' in the name and if that fails it returns the first image file from the manifest. The function also logs the relative path to the image within the epub which was identified as cover image. If no image is found, it raises an error.

Parameters:

Name Type Description Default
fp

Filepath to EPUB file

required

Returns:

Type Description

Raw bytes of the cover image

Raises:

Type Description
IsccExtractionError

If no cover image can be found.

epub_process_container(fp, **options) #

Extract and process images from EPUB file. Skips processing for fixed layout EPUBs.

Parameters:

Name Type Description Default
fp

Filepath to EPUB file

required
options

Processing options

{}

Returns:

Type Description

List of IsccMeta objects for embedded images

epub_extract_images(fp, output_dir) #

Extract images from EPUB file to output directory where both width and height are >= min_image_size.

Parameters:

Name Type Description Default
fp

Filepath to EPUB file

required
output_dir

Directory to extract images to

required

Returns:

Type Description

List of paths to extracted images

is_fixed_layout_epub(fp) #

Check if an EPUB is a fixed layout publication.

Parameters:

Name Type Description Default
fp

Path to EPUB file

required

Returns:

Type Description

True if the EPUB is fixed layout, False otherwise