Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultAccept is the default Accept header sent on upstream requests. DefaultAccept = "image/jpeg,image/webp;q=0.8,image/png;q=0.4,image/svg+xml;q=0.3,image/gif;q=0.2,application/pdf;q=0.1" // DefaultServer is the default Server header sent with responses. DefaultServer = "Fotomat" // DefaultUserAgent is the default User-Agent header sent on upstream requests. DefaultUserAgent = "Fotomat (http://fotomat.org)" )
Variables ¶
View Source
var ( // ErrBadOption is returned when option values are out of range. ErrBadOption = errors.New("bad option specified") // ErrTooBig is returned when an image is too wide or tall. ErrTooBig = errors.New("image is too wide or tall") // ErrTooSmall is returned when an image is too small. ErrTooSmall = errors.New("image is too small") )
View Source
var ( // ErrAborted means the operation wasn't executed because the // Request.Aborted channel was closed by the caller. ErrAborted = errors.New("thumbnail request aborted") )
Functions ¶
Types ¶
type Options ¶
type Options struct { // Width and Height are the optional maximum sizes of output image, // in pixels. If Crop is false, the original aspect ratio is // preserved and the more restrictive of Width or Height are used. Width int Height int // Crop enables crop mode, where exact supplied Width:Height aspect // ratio is preserved and excess pixels are trimmed from the sides. Crop bool // Sharpen runs a mild sharpening pass on downsampled images. Sharpen bool // BlurSigma performs a gaussian blur with specified sigma. BlurSigma float64 // MaxBufferPixels specifies how large of an intermediate image // buffer to allow, in pixels. RAM usage will be a few bytes per pixel. MaxBufferPixels int // MaxQueueDuration limits the amount of time spent in a queue before processing starts. MaxQueueDuration time.Duration // MaxProcessingDuration limits the amount of time processing an // image, after which it is assumed the operation has crashed and // the server aborts, killing all outstanding requests. MaxProcessingDuration time.Duration // Save specifies the format.SaveOptions to use when compressing the modified image. Save format.SaveOptions }
Options specifies how a Thumbnail operation should modify an image.
type Pool ¶
type Pool struct { RequestCh chan *Request // contains filtered or unexported fields }
Pool represents a Thumbnail worker pool. VIPS keeps thread-local caches, which we retain control over through a combination of a pool of worker goroutines and using runtime.LockOSThread() within those workers.
func NewPool ¶
NewPool creates a Thumbnail worker pool with a given number of worker threads and queue length.
type Proxy ¶
type Proxy struct { Director func(*http.Request) (Options, int) Client *http.Client Accept string Server string UserAgent string // contains filtered or unexported fields }
Proxy represents an HTTP proxy that can optionally run its contents through Thumbnail. Must be created with NewProxy.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.