img

package
v0.0.0-...-d1a9080 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

func New

func New(r io.Reader) (Image, error)

New create a new Image instance, using the ImageNative implementation. Since there's no other implementation at the moment, let's keep it this way for now.

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

type ImageFilter func(Image) error

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) Height

func (im *NativeImage) Height() uint

Height returns the image height.

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.

func (*NativeImage) Width

func (im *NativeImage) Width() uint

Width returns the image width.

Jump to

Keyboard shortcuts

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