Documentation ¶
Index ¶
- Variables
- type Image
- type ImageCompression
- type ImageFilter
- type NativeImage
- func (im *NativeImage) Close() error
- func (im *NativeImage) Encode(w io.Writer) error
- func (im *NativeImage) Fit(w, h uint) error
- func (im *NativeImage) Format() string
- func (im *NativeImage) Gray16() error
- func (im *NativeImage) Grayscale() error
- func (im *NativeImage) Height() uint
- func (im *NativeImage) Image() image.Image
- func (im *NativeImage) Pipeline(filters ...ImageFilter) error
- func (im *NativeImage) Resize(w, h uint) error
- func (im *NativeImage) SetCompression(c ImageCompression) error
- func (im *NativeImage) SetFormat(f string) error
- func (im *NativeImage) SetQuality(q uint8) error
- func (im *NativeImage) Width() uint
Constants ¶
This section is empty.
Variables ¶
var Gray16Palette = []color.Color{ color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x11, 0x11, 0x11, 0xff}, color.RGBA{0x22, 0x22, 0x22, 0xff}, color.RGBA{0x33, 0x33, 0x33, 0xff}, color.RGBA{0x44, 0x44, 0x44, 0xff}, color.RGBA{0x55, 0x55, 0x55, 0xff}, color.RGBA{0x66, 0x66, 0x66, 0xff}, color.RGBA{0x77, 0x77, 0x77, 0xff}, color.RGBA{0x88, 0x88, 0x88, 0xff}, color.RGBA{0x99, 0x99, 0x99, 0xff}, color.RGBA{0xaa, 0xaa, 0xaa, 0xff}, color.RGBA{0xbb, 0xbb, 0xbb, 0xff}, color.RGBA{0xcc, 0xcc, 0xcc, 0xff}, color.RGBA{0xdd, 0xdd, 0xdd, 0xff}, color.RGBA{0xee, 0xee, 0xee, 0xff}, color.RGBA{0xff, 0xff, 0xff, 0xff}, }
Gray16Palette is a 16 level b&w palette.
Functions ¶
This section is empty.
Types ¶
type Image ¶
type Image interface { Close() error Format() string Width() uint Height() uint SetFormat(string) error SetCompression(ImageCompression) error SetQuality(uint8) error Resize(uint, uint) error Fit(uint, uint) error Grayscale() error Gray16() error Pipeline(...ImageFilter) error Encode(io.Writer) error }
Image describes the interface of an image manipulation object.
type ImageCompression ¶
type ImageCompression uint8
ImageCompression is the compression level used for PNG images
const ( // CompressionFast is a fast method. CompressionFast ImageCompression = iota // CompressionBest is the best space saving method. CompressionBest )
type ImageFilter ¶
ImageFilter is a filter application function used by the Pipeline method of an Image instance.
type NativeImage ¶
type NativeImage struct {
// contains filtered or unexported fields
}
NativeImage is the Image implementation using Go native image tools.
func NewNativeImage ¶
func NewNativeImage(r io.Reader) (*NativeImage, error)
NewNativeImage returns an Image instance using Go native image tools.
func (*NativeImage) Close ¶
func (im *NativeImage) Close() error
Close frees the resources used by the image and must be called when you're done processing it.
func (*NativeImage) Encode ¶
func (im *NativeImage) Encode(w io.Writer) error
Encode encodes the image to an io.Writer.
func (*NativeImage) Fit ¶
func (im *NativeImage) Fit(w, h uint) error
Fit resizes the image keeping the aspect ratio and staying within the given width and height.
func (*NativeImage) Format ¶
func (im *NativeImage) Format() string
Format returns the image format.
func (*NativeImage) Gray16 ¶
func (im *NativeImage) Gray16() error
Gray16 transforms the image to a 16 gray levels palette, applying a Floyd Steinberg dithering. It is better to convert the image to grayscale before this operation.
func (*NativeImage) Grayscale ¶
func (im *NativeImage) Grayscale() error
Grayscale transforms the image to a grayscale version.
func (*NativeImage) Image ¶
func (im *NativeImage) Image() image.Image
Image returns the wrapped image instance.
func (*NativeImage) Pipeline ¶
func (im *NativeImage) Pipeline(filters ...ImageFilter) error
Pipeline apply all the given ImageFilter functions to the image.
func (*NativeImage) Resize ¶
func (im *NativeImage) Resize(w, h uint) error
Resize resizes the image to the given width and height.
func (*NativeImage) SetCompression ¶
func (im *NativeImage) SetCompression(c ImageCompression) error
SetCompression sets the compression level of PNG encoding.
func (*NativeImage) SetFormat ¶
func (im *NativeImage) SetFormat(f string) error
SetFormat sets the encoding format. When none is set, it will use the original format or fallback to JPEG.
func (*NativeImage) SetQuality ¶
func (im *NativeImage) SetQuality(q uint8) error
SetQuality sets the quality of JEPG encoding.