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:
- Create a writer with NewContainer.
- Add image pages with ContainerWriter.AddPage.
- Write the completed container with ContainerWriter.WriteOnDiskAndClose.
Index ¶
Constants ¶
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 ¶
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. |