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: 1. Checking the EPUB2 metadata cover reference 2. Checking the EPUB3 cover-image manifest property 3. Scanning for image files with 'cover' in the name 4. Falling back to the first image file from the manifest
URL-encoded paths in the OPF manifest are decoded before zip archive lookup. 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 |