book

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Portrait = iota
	Landscape
	Square
)

Variables

This section is empty.

Functions

func IsSupportedColorDepth added in v0.2.0

func IsSupportedColorDepth(depth uint) error

Types

type Book

type Book struct {
	Filepath  string
	Title     string
	PageCount int
	Config    BookConfig
	// contains filtered or unexported fields
}

func NewBook

func NewBook(path string, config BookConfig) (*Book, error)

func (*Book) LoadPage

func (b *Book) LoadPage(pageNo int) (*Page, error)

type BookConfig

type BookConfig struct {
	Density float64
	IsRTL   bool
	BgColor []color.Color
}

type GrayscaleConfig added in v0.2.0

type GrayscaleConfig struct {
	PageRange  *PageRange
	ColorDepth uint
}

type Orientation

type Orientation int

func (Orientation) String

func (o Orientation) String() string

type Page

type Page struct {
	PageNo      int
	OtherPageNo int // the other page number that this page connected with
	// contains filtered or unexported fields
}

func (*Page) Connect

func (left *Page) Connect(right *Page) (*Page, error)

func (*Page) ConvertToGrayscale

func (p *Page) ConvertToGrayscale(cfg GrayscaleConfig) error

func (*Page) Destroy

func (p *Page) Destroy()

func (Page) Filename

func (p Page) Filename(suffix string) string

func (Page) Filepath

func (p Page) Filepath(dir string, suffix string) string

func (*Page) IsDoublePageSpread

func (left *Page) IsDoublePageSpread(right *Page, cfg SpreadConfig) (bool, error)

func (*Page) LeftRight

func (p *Page) LeftRight(other *Page) (left *Page, right *Page)

func (Page) Rect

func (p Page) Rect() Rect

func (*Page) ResizeToFit

func (p *Page) ResizeToFit(screen Size) error

func (Page) Size

func (p Page) Size() Size

func (*Page) Trim

func (p *Page) Trim(cfg TrimConfig, fuzzP float64) error

func (Page) WriteFile

func (p Page) WriteFile(dir string) (string, string, error)

type PageExtractor added in v0.3.0

type PageExtractor interface {
	Name() string
	Detect() error
	Extract(inputFile string, page int, dpi float64, outputFile string) error
}

func FindExtractor added in v0.3.0

func FindExtractor() (PageExtractor, error)

type PageRange

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

func NewPageRange

func NewPageRange() *PageRange

func (*PageRange) Add

func (pr *PageRange) Add(start int, end int)

func (PageRange) All

func (pr PageRange) All() []int

func (PageRange) Contains

func (pr PageRange) Contains(page int) bool

func (PageRange) First

func (pr PageRange) First() int

func (PageRange) Last

func (pr PageRange) Last() int

func (PageRange) PageCount

func (pr PageRange) PageCount() int

func (*PageRange) Parse

func (pr *PageRange) Parse(str string, total int) error

func (PageRange) String

func (pr PageRange) String() string

type Point

type Point struct {
	X int
	Y int
}

TODO: Use image.Point

func (Point) String

func (p Point) String() string

func (Point) TranslateBy

func (p Point) TranslateBy(dx int, dy int) Point

type Rect

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

TODO: Use image.Rectange

func FromRectangle added in v0.3.0

func FromRectangle(r image.Rectangle) Rect

func (Rect) BoundBy

func (r Rect) BoundBy(frame Rect) Rect

func (Rect) InsetBy

func (r Rect) InsetBy(dx int, dy int) Rect

func (Rect) LeftEdge

func (r Rect) LeftEdge(width uint, margin uint) Rect

func (Rect) MaxX

func (r Rect) MaxX() int

func (Rect) MaxY

func (r Rect) MaxY() int

func (Rect) MinX

func (r Rect) MinX() int

func (Rect) MinY

func (r Rect) MinY() int

func (Rect) MoveInside

func (r Rect) MoveInside(frame Rect) Rect

func (Rect) RightEdge

func (r Rect) RightEdge(width uint, margin uint) Rect

func (Rect) String

func (r Rect) String() string

func (Rect) ToRectangle added in v0.3.0

func (r Rect) ToRectangle() image.Rectangle

func (Rect) TranslateBy

func (r Rect) TranslateBy(dx int, dy int) Rect

type Size

type Size struct {
	Width  uint
	Height uint
}

func SizeFromBounds added in v0.3.0

func SizeFromBounds(b image.Rectangle) Size

func (Size) AspectFitIn

func (s Size) AspectFitIn(box Size, enlarge bool) Size

func (Size) CanFitIn

func (s Size) CanFitIn(box Size) bool

func (Size) Orientation

func (s Size) Orientation() Orientation

func (Size) Rotate

func (s Size) Rotate() Size

func (Size) ScaleBy

func (s Size) ScaleBy(f float64) Size

func (Size) String

func (s Size) String() string

type SpreadConfig

type SpreadConfig struct {
	Enabled    bool
	EdgeWidth  uint
	EdgeMargin uint
	BgDistort  []float64
	LrDistort  float64
}

type TrimConfig

type TrimConfig struct {
	Enabled  bool
	MinSizeP float64
	Margin   int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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