Documentation ¶
Index ¶
- Constants
- Variables
- func Save(image *vips.Image, options SaveOptions) ([]byte, error)
- type Format
- func (format Format) CanLoadBytes() bool
- func (format Format) CanLoadFile() bool
- func (format Format) LoadBytes(blob []byte) (*vips.Image, error)
- func (format Format) LoadFile(filename string) (*vips.Image, error)
- func (format Format) MetadataBytes(blob []byte) (Metadata, error)
- func (format Format) MetadataFile(filename string) (Metadata, error)
- func (format Format) String() string
- type Metadata
- type Orientation
- type SaveOptions
Constants ¶
const ( // DefaultQuality is used when SaveOptions.Quality is unspecified. DefaultQuality = 85 // DefaultCompression is used when SaveOptions.Compression is unspecified. DefaultCompression = 6 )
Variables ¶
var ( // ErrInvalidOperation is returned for an invalid operation on this image format. ErrInvalidOperation = errors.New("invalid operation") // ErrUnknownFormat is returned when the given image is in an unknown format. ErrUnknownFormat = errors.New("unknown image format") )
var ErrInvalidSaveFormat = errors.New("invalid save format")
ErrInvalidSaveFormat is returned if the specified Format can't be written to.
Functions ¶
Types ¶
type Format ¶
type Format int
Format of compressed image.
func DetectFormat ¶
DetectFormat detects the Format of the supplied byte slice.
func (Format) CanLoadBytes ¶
CanLoadBytes returns true if we know how to load this format from a byte slice.
func (Format) CanLoadFile ¶
CanLoadFile returns true if we know how to load this format from a file.
func (Format) MetadataBytes ¶
MetadataBytes parses an image byte slice in known format and returns Metadata or an error.
func (Format) MetadataFile ¶
MetadataFile parses an image file in known format and returns Metadata or an error.
type Metadata ¶
type Metadata struct { Width int Height int Format Format Orientation Orientation HasAlpha bool }
Metadata is the currently-known metadata about an Image.
func MetadataBytes ¶
MetadataBytes parses an image byte slice and returns Metadata or an error.
func MetadataImage ¶
MetadataImage returns Metadata from an Image. Format is always unset.
type Orientation ¶
type Orientation int
Orientation is the current Image orientation, as stored by a camera.
const ( Undefined Orientation = iota TopLeft TopRight BottomRight BottomLeft LeftTop RightTop RightBottom LeftBottom )
Orientation values as defined by EXIF.
func DetectOrientation ¶
func DetectOrientation(image *vips.Image) Orientation
DetectOrientation detects the current Image Orientation from the EXIF header.
func (Orientation) Apply ¶
func (orientation Orientation) Apply(image *vips.Image) error
Apply executes a set of operations to change the pixel ordering from orientation to TopLeft.
func (Orientation) Crop ¶
Crop translates crop parameters from virtual coordinates to match the current physical Orientation.
func (Orientation) Dimensions ¶
func (orientation Orientation) Dimensions(width, height int) (int, int)
Dimensions translates a virtual width and height to match the current physical Orientation.
type SaveOptions ¶
type SaveOptions struct { // Format is the Format that an image is saved in. If unspecified, the best output format for a given input image is selected. Format Format // JPEG or WebP quality for an output image (1-100). Quality int // Compress is the GZIP compression setting to use for PNG images (1-9). Compression int // AllowWebp allows automatic selection of WebP format, if reader can support it. AllowWebp bool // Lossless allows selection of a lossless output format. Lossless bool // LossyIfPhoto uses a lossy format if it detects that an image is a photo. LossyIfPhoto bool }
SaveOptions specifies how an image should be saved.