cbz

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package cbz writes and reads comic book archives: a ZIP with the pages stored (not compressed, images already are) as 0001.jpg, 0002.png, … and a ComicInfo.xml that other readers understand.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImage = errors.New("cbz: page is not a supported image")

ErrNotImage is a page that isn't a known image type.

Functions

This section is empty.

Types

type Archive

type Archive struct {
	// contains filtered or unexported fields
}

Archive is an archive opened for reading pages.

func Open

func Open(r io.ReaderAt, size int64) (*Archive, error)

Open reads an archive's directory.

func (*Archive) Page

func (a *Archive) Page(i int) (contentType string, r io.ReadCloser, size int64, err error)

Page opens page i (from 0).

func (*Archive) Pages

func (a *Archive) Pages() int

Pages is the number of pages.

type ComicInfo

type ComicInfo struct {
	XMLName     xml.Name `xml:"ComicInfo"`
	Title       string   `xml:"Title,omitempty"`
	Series      string   `xml:"Series,omitempty"`
	Number      string   `xml:"Number,omitempty"`
	Volume      int      `xml:"Volume,omitempty"`
	Summary     string   `xml:"Summary,omitempty"`
	Notes       string   `xml:"Notes,omitempty"`
	Year        int      `xml:"Year,omitempty"`
	Writer      string   `xml:"Writer,omitempty"`
	Penciller   string   `xml:"Penciller,omitempty"`
	Translator  string   `xml:"Translator,omitempty"`
	Genre       string   `xml:"Genre,omitempty"`
	Web         string   `xml:"Web,omitempty"`
	PageCount   int      `xml:"PageCount,omitempty"`
	LanguageISO string   `xml:"LanguageISO,omitempty"`
	Manga       string   `xml:"Manga,omitempty"`
	AgeRating   string   `xml:"AgeRating,omitempty"`
}

ComicInfo is the ComicInfo.xml metadata (the fields other readers use).

type Result

type Result struct {
	Pages  int
	Bytes  int64
	SHA256 string
}

Result describes a finished archive.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer builds an archive in a file.

func Create

func Create(p string) (*Writer, error)

Create starts an archive at path.

func (*Writer) Abort

func (w *Writer) Abort()

Abort discards the archive.

func (*Writer) AddPage

func (w *Writer) AddPage(contentType string, r io.Reader) error

AddPage appends the next page.

func (*Writer) Finish

func (w *Writer) Finish(info ComicInfo) (Result, error)

Finish adds ComicInfo.xml, closes the archive and returns its size and checksum.

Jump to

Keyboard shortcuts

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