image

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinJPEGQuality = jpeg.DefaultQuality // 75
	MinWebpQuality = 80
)

consts

Variables

View Source
var (
	ErrorFormat     = errors.New("Invalid or unsupported Image Format")
	ErrOrigTooSmall = errors.New("Original Image Too Small")
)

Functions

func Ext2Format added in v1.4.1

func Ext2Format(s string) string

Ext2Format ...

func Format2Ext added in v1.4.1

func Format2Ext(f string) string

Format2Ext ...

func GetPoint

func GetPoint(sm, wm image.Point, pos Position) (pt image.Point)

GetPoint ...

func SaveTo

func SaveTo(w io.Writer, m image.Image, opt WriteOption) (n int, err error)

SaveTo ...

func Thumbnail

func Thumbnail(r io.Reader, w io.Writer, topt ThumbOption) error

Thumbnail ...

func ThumbnailFile

func ThumbnailFile(src, dest string, topt ThumbOption) (err error)

func ThumbnailImage

func ThumbnailImage(img image.Image, topt *ThumbOption) (image.Image, error)

ThumbnailImage ...

func Watermark

func Watermark(r, wr io.Reader, w io.Writer, wo WaterOption) error

Watermark ...

func WatermarkFile

func WatermarkFile(src, dest string, wo WaterOption) (err error)

func WatermarkImage

func WatermarkImage(img, water image.Image, pos Position, opacity Opacity) (image.Image, error)

WatermarkImage add a watermark and copyright into a image with position and opacity

Types

type Attr

type Attr struct {
	Width   Dimension `json:"width"`
	Height  Dimension `json:"height"`
	Quality Quality   `json:"quality,omitempty"` // Original quality
	Size    Size      `json:"size,omitempty"`    // Original size
	Ext     string    `json:"ext"`               // file extension include dot
	Mime    string    `json:"mime,omitempty"`    // content type
	Name    string    `json:"name,omitempty"`    // Deprecated
}

Attr ...

func NewAttr

func NewAttr(w, h uint, f string) *Attr

NewAttr ...

func (*Attr) FromMap

func (a *Attr) FromMap(m map[string]interface{})

FromMap ...

func (*Attr) Scan

func (a *Attr) Scan(b interface{}) error

Scan implements the Scanner interface.

func (Attr) ToMap

func (a Attr) ToMap() map[string]interface{}

ToMap ...

func (Attr) Value

func (a Attr) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type CountWriter

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

CountWriter ...

func (*CountWriter) Len

func (cw *CountWriter) Len() int

Len return count value

func (*CountWriter) Write

func (cw *CountWriter) Write(p []byte) (n int, err error)

Write implements for io.Writer

type Dimension

type Dimension uint32

Dimension ...

type Image

type Image struct {
	*Attr
	Format string
	// contains filtered or unexported fields
}

Image ...

func Open

func Open(rs io.ReadSeeker) (*Image, error)

Open ...

func (*Image) SaveTo

func (im *Image) SaveTo(w io.Writer, opt WriteOption) error

SaveTo ...

type Opacity

type Opacity uint8

Opacity ...

type Position

type Position uint8

Position ...

const (
	BottomRight Position = iota
	BottomLeft
	TopLeft
	TopRight
	Center
	Golden
)

Position

type Quality

type Quality uint8

Quality ...

type Size

type Size uint32

Size ...

type ThumbOption

type ThumbOption struct {
	Width, Height       uint
	MaxWidth, MaxHeight uint
	IsFit               bool
	IsCrop              bool
	CropX, CropY        int

	WriteOption
	// contains filtered or unexported fields
}

ThumbOption ...

func (ThumbOption) String

func (topt ThumbOption) String() string

type WaterOption

type WaterOption struct {
	Pos      Position
	Opacity  Opacity
	Filename string
	WriteOption
}

WaterOption ...

type WriteOption

type WriteOption struct {
	Format   string
	StripAll bool
	Quality  Quality
}

WriteOption ...

Jump to

Keyboard shortcuts

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