Documentation ¶
Index ¶
- Constants
- Variables
- type Document
- func (d *Document) AddImageLayer(image Image, imagename string, format string, w, h float64)
- func (d *Document) AddPage(image Image, imagename string, words []Word, format string) error
- func (d *Document) AddWords(words []Word)
- func (d *Document) GetPageConfiguration(iw, ih float64) (w, h float64, orientation Orientation)
- func (d *Document) SetDebug(enabled bool)
- func (d *Document) SetOrientation(orientation Orientation)
- func (d *Document) SetTextScaling(mode TextScaling)
- type Image
- func (i *Image) Adjust(threshold float32) *Image
- func (i *Image) CPIX() *C.PIX
- func (i Image) Dimensions() (int32, int32, int32)
- func (i Image) FormatString() string
- func (i Image) Reader(format string) (*bytes.Buffer, string, error)
- func (i Image) ReaderJPEG(quality int, progressive bool) (*bytes.Buffer, error)
- func (i Image) ReaderPNG(gamma float32) (*bytes.Buffer, error)
- func (i *Image) Scale(w, h int32) *Image
- func (i *Image) ScaleDown(w, h int32) *Image
- type Orientation
- type Tess
- type TextScaling
- type Word
Constants ¶
const ( // AutoOrientation chooses orientation based on longest edge AutoOrientation Orientation = "auto" PortraitOrientation = "portrait" LandscapeOrientation = "landscape" )
Different orientation modes.
const ( // NoTextScaling specifies that no text scaling will be performed. NoTextScaling TextScaling = "off" // ContainTextScaling fits the text to the detected word boundary, // whilst maintaining the correct aspect ratio for the font. ContainTextScaling = "contain" // MatchTextScaling fits the text to the detected word boundary exactly, // scaling the font if required. MatchTextScaling = "match" )
const DefaultJPEGCompression int = 75
Variables ¶
var JPEGCompression int = DefaultJPEGCompression
Functions ¶
This section is empty.
Types ¶
type Document ¶
Document is a wrapped version of gofpdf.Fpd which adds additional methods for constructing documents with OCR-generated text.
func NewDocument ¶
NewDocument returns a new Document of the specified size.
func (*Document) AddImageLayer ¶
AddImageLayer adds the specified image to the page, embedding it using the given format, and appear at the specified size (in page units).
func (*Document) AddPage ¶
AddPage appends the given image to the document, annotating the document with the detected words. Ensure `name` is unique for each distinct image.
func (*Document) GetPageConfiguration ¶
func (d *Document) GetPageConfiguration(iw, ih float64) ( w, h float64, orientation Orientation)
GetPageConfiguration returns a suitable page size and orientation to contain an image of the specified dimensions.
func (*Document) SetDebug ¶
SetDebug enables debug mode, in which detected words are outlined, and the text layer is arranged on top of the image (scan) layer.
func (*Document) SetOrientation ¶
func (d *Document) SetOrientation(orientation Orientation)
SetOrientation sets the orientation of new pages
func (*Document) SetTextScaling ¶
func (d *Document) SetTextScaling(mode TextScaling)
SetTextScaling enables the scaling of embedded text such that it matches the same area that the original text was detected.
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
func NewImageFromFile ¶
NewImageFromFile creates and returns a new image loaded from the given file path.
func (*Image) Adjust ¶
Adjust improves the clarity and contrast of the image, generally reducing scanning artifacts.
func (Image) Dimensions ¶
Dimensions calculates the width, height and colour depth of the image.
func (Image) FormatString ¶
FormatString returns the image format as a string, e.g. 'jpg'
func (Image) Reader ¶
Reader returns an io.Reader for the image data. If format is not specified, the reader will produce image data in the original image format. Otherwise, `format` must be either "jpeg" or "png"
func (Image) ReaderJPEG ¶
ReaderJPEG returns an io.Reader for the image data, returning a compressed JPEG of the specified quality (0-100).
type Tess ¶
type Tess struct {
// contains filtered or unexported fields
}
func (*Tess) SetImagePix ¶
func (t *Tess) SetImagePix(pix *C.struct_Pix)
SetImagePix sets the image to perform recognition on