comicfile

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 11 Imported by: 0

README

comicfile

Go package for creating manga or comic chapter files from image pages. It provides a common container interface and can write output as CBZ, PDF, EPUB, or a plain directory, with optional comic metadata.

Installation

go get github.com/arimatakao/comicfile

Runnable examples are grouped by format in the examples directory. Each uses -c to create its file.* container and -r to read it.

Documentation

Overview

Package comicfile writes and reads comic or manga chapters stored as CBZ, PDF, EPUB, or directories of image files.

A typical flow is:

  1. Create a writer with NewContainer.
  2. Add image pages with ContainerWriter.AddPage.
  3. Write the completed container with ContainerWriter.WriteOnDiskAndClose.

Index

Constants

View Source
const (
	// CBZ_EXT is the filename extension for CBZ archives.
	CBZ_EXT = "cbz"
	// PDF_EXT is the filename extension for PDF documents.
	PDF_EXT = "pdf"
	// EPUB_EXT is the filename extension for EPUB books.
	EPUB_EXT = "epub"
	// DIR_EXT identifies the directory-based output format.
	DIR_EXT = "dir"
)

Variables

This section is empty.

Functions

func IsNotSupported

func IsNotSupported(fileFormat string) bool

IsNotSupported reports whether fileFormat is not one of the supported container extensions.

Types

type ContainerReader

type ContainerReader interface {
	// Close releases resources held by the reader.
	io.Closer
	// TotalPages returns the number of pages in the container.
	TotalPages() int
	// ErrPages returns the number of pages that could not be read.
	ErrPages() int
	// Metadata returns the metadata stored in the container.
	Metadata() *metadata.Metadata
	// Page returns the image for the page at index.
	Page(index int) (image.Image, error)
}

ContainerReader provides page images and metadata from a comic chapter container.

func OpenContainer

func OpenContainer(path string) (ContainerReader, error)

OpenContainer opens the comic chapter container at path.

The container format is selected from the path: a directory, or a file with a CBZ_EXT, EPUB_EXT, or PDF_EXT extension.

type ContainerWriter

type ContainerWriter interface {
	// WriteOnDiskAndClose finalizes the container and writes it below outputDir.
	// outputFileName is used as the output name; m supplies metadata, and
	// chapterRange optionally replaces the chapter portion of an EPUB title.
	WriteOnDiskAndClose(outputDir string, outputFileName string, m metadata.Metadata, chapterRange string) error
	// AddPage appends imageBytes as a page. fileExt is the image filename
	// extension, without a leading period.
	AddPage(fileExt string, imageBytes []byte) error
}

ContainerWriter accepts comic page images and writes a completed chapter to disk.

func NewContainer

func NewContainer(extension string) (ContainerWriter, error)

NewContainer creates a container by file extension.

extension must be one of CBZ_EXT, PDF_EXT, EPUB_EXT, or DIR_EXT.

Directories

Path Synopsis
examples
cbz command
Command cbz creates or reads file.cbz.
Command cbz creates or reads file.cbz.
dir command
Command dir creates or reads the file directory.
Command dir creates or reads the file directory.
epub command
Command epub creates or reads file.epub.
Command epub creates or reads file.epub.
pdf command
Command pdf creates or reads file.pdf.
Command pdf creates or reads file.pdf.
internal
container
Package container provides shared implementation details for output formats.
Package container provides shared implementation details for output formats.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL