Documentation
¶
Index ¶
- Constants
- Variables
- type BackgroundSetter
- type Config
- type FocusPoint
- type GravityEnum
- type GravitySetter
- type HexColor
- type Imgproxy
- type ImgproxyURLData
- func (i *ImgproxyURLData) Background(bg BackgroundSetter) *ImgproxyURLData
- func (i *ImgproxyURLData) Blur(sigma int) *ImgproxyURLData
- func (i *ImgproxyURLData) CacheBuster(buster string) *ImgproxyURLData
- func (i *ImgproxyURLData) Crop(width int, height int, gravity GravitySetter) *ImgproxyURLData
- func (i *ImgproxyURLData) DPR(dpr int) *ImgproxyURLData
- func (i *ImgproxyURLData) Enlarge(enlarge int) *ImgproxyURLData
- func (i *ImgproxyURLData) Format(extension string) *ImgproxyURLData
- func (i *ImgproxyURLData) Generate(uri string) (string, error)
- func (i *ImgproxyURLData) Gravity(g GravitySetter) *ImgproxyURLData
- func (i *ImgproxyURLData) Height(height int) *ImgproxyURLData
- func (i *ImgproxyURLData) Preset(presets ...string) *ImgproxyURLData
- func (i *ImgproxyURLData) Quality(quality int) *ImgproxyURLData
- func (i *ImgproxyURLData) Resize(resizingType ResizingType, width int, height int, enlarge bool, extend bool) *ImgproxyURLData
- func (i *ImgproxyURLData) ResizingType(resizingType ResizingType) *ImgproxyURLData
- func (i *ImgproxyURLData) SetOption(key, value string) *ImgproxyURLData
- func (i *ImgproxyURLData) Sharpen(sigma int) *ImgproxyURLData
- func (i *ImgproxyURLData) Size(width int, height int, enlarge bool) *ImgproxyURLData
- func (i *ImgproxyURLData) Watermark(opacity int, position WatermarkPosition, offset *WatermarkOffset, scale int) *ImgproxyURLData
- func (i *ImgproxyURLData) Width(width int) *ImgproxyURLData
- type OffsetGravity
- type RGBColor
- type ResizingType
- type WatermarkOffset
- type WatermarkPosition
Constants ¶
const ( // Resizes the image while keeping aspect ratio to fit a given size. ResizingTypeFit = ResizingType("fit") // Resizes the image while keeping aspect ratio to fill a given size and crops projecting parts. ResizingTypeFill = ResizingType("fill") // The same as fill, but if the resized image is smaller than the requested size, imgproxy will crop the result to keep the requested aspect ratio. ResizingTypeFillDown = ResizingType("fill-down") // Resizes the image without keeping the aspect ratio. ResizingTypeForce = ResizingType("force") // If both source and resulting dimensions have the same orientation (portrait or landscape), imgproxy will use fill. Otherwise, it will use fit. ResizingTypeAuto = ResizingType("auto") )
ResizingType enum.
const ( // Default gravity position. GravityEnumCenter = GravityEnum("ce") // Top edge. GravityEnumNorth = GravityEnum("no") // Bottom edge. GravityEnumSouth = GravityEnum("so") // Right edge. GravityEnumEast = GravityEnum("ea") // Left edge. GravityEnumWest = GravityEnum("we") // Top-right corner. GravityEnumNorthEast = GravityEnum("noea") // Top-left corner. GravityEnumNorthWest = GravityEnum("nowe") // Bottom-right corner. GravityEnumSouthEast = GravityEnum("soea") // Bottom-left corner. GravityEnumSouthWest = GravityEnum("sowe") // Libvips detects the most "interesting" section of the image and considers it as the center of the resulting image. GravityEnumSmart = GravityEnum("sm") )
GravityEnum constants.
const ( WatermarkPositionCenter = WatermarkPosition("ce") WatermarkPositionNorth = WatermarkPosition("no") WatermarkPositionSouth = WatermarkPosition("so") WatermarkPositionEast = WatermarkPosition("ea") WatermarkPositionWest = WatermarkPosition("we") WatermarkPositionNorthEast = WatermarkPosition("noea") WatermarkPositionNorthWest = WatermarkPosition("nowe") WatermarkPositionSouthEast = WatermarkPosition("soea") WatermarkPositionSouthWest = WatermarkPosition("sowe") WatermarkPositionReplicate = WatermarkPosition("re") )
WatermarkPosition constants.
Variables ¶
var ErrInvalidSignature = stdErrs.New("invalid signature size")
ErrInvalidSignature error.
Functions ¶
This section is empty.
Types ¶
type BackgroundSetter ¶
type BackgroundSetter interface {
SetBgOption(*ImgproxyURLData) *ImgproxyURLData
}
BackgroundSetter interface to set the background option.
type FocusPoint ¶
FocusPoint holds the coordinates of the focus point.
func (FocusPoint) GetStringOption ¶
func (f FocusPoint) GetStringOption() string
GetStringOption gets the focus point value as string.
func (FocusPoint) SetGravityOption ¶
func (f FocusPoint) SetGravityOption(i *ImgproxyURLData) *ImgproxyURLData
SetGravityOption sets gravity option.
type GravityEnum ¶
type GravityEnum string
GravityEnum holds a gravity option value.
func (GravityEnum) GetStringOption ¶
func (g GravityEnum) GetStringOption() string
GetStringOption gets the gravity value as string.
func (GravityEnum) SetGravityOption ¶
func (g GravityEnum) SetGravityOption(i *ImgproxyURLData) *ImgproxyURLData
SetGravityOption sets the gravity option.
type GravitySetter ¶
type GravitySetter interface {
SetGravityOption(i *ImgproxyURLData) *ImgproxyURLData
GetStringOption() string
}
GravitySetter interface to set and get a gravity option.
type HexColor ¶
type HexColor string
HexColor holds an hexadecimal format color.
func (HexColor) SetBgOption ¶
func (h HexColor) SetBgOption(i *ImgproxyURLData) *ImgproxyURLData
SetBgOption sets the background option.
type Imgproxy ¶
type Imgproxy struct {
// contains filtered or unexported fields
}
Imgproxy is a URL builder helper for imgproxy.
func NewImgproxy ¶
NewImgproxy returns a new *Imgproxy.
func (*Imgproxy) Builder ¶
func (i *Imgproxy) Builder() *ImgproxyURLData
Builder returns a *ImgproxyURLData that can be used to construct an imgproxy URL.
type ImgproxyURLData ¶
ImgproxyURLData is a struct that contains the data required for generating an imgproxy URL.
func (*ImgproxyURLData) Background ¶
func (i *ImgproxyURLData) Background(bg BackgroundSetter) *ImgproxyURLData
Background fills the resulting image background with the specified color. RGBColor are the red, green and blue channel values of the background color (0-255). HexColor is a hex-coded value of the color. Useful when you convert an image with alpha-channel to JPEG.
func (*ImgproxyURLData) Blur ¶
func (i *ImgproxyURLData) Blur(sigma int) *ImgproxyURLData
Blur applies a gaussian blur filter to the resulting image. The value of sigma defines the size of the mask imgproxy will use.
func (*ImgproxyURLData) CacheBuster ¶
func (i *ImgproxyURLData) CacheBuster(buster string) *ImgproxyURLData
CacheBuster doesn’t affect image processing but its changing allows for bypassing the CDN, proxy server and browser cache. Useful when you have changed some things that are not reflected in the URL, like image quality settings, presets, or watermark data. It’s highly recommended to prefer the cachebuster option over a URL query string because that option can be properly signed.
func (*ImgproxyURLData) Crop ¶
func (i *ImgproxyURLData) Crop(width int, height int, gravity GravitySetter) *ImgproxyURLData
Crop sets the crop option.
func (*ImgproxyURLData) DPR ¶
func (i *ImgproxyURLData) DPR(dpr int) *ImgproxyURLData
DPR controls the output density of your image.
func (*ImgproxyURLData) Enlarge ¶
func (i *ImgproxyURLData) Enlarge(enlarge int) *ImgproxyURLData
Enlarge enlarges the image.
func (*ImgproxyURLData) Format ¶
func (i *ImgproxyURLData) Format(extension string) *ImgproxyURLData
Format specifies the resulting image format. Alias for the extension part of the URL.
func (*ImgproxyURLData) Generate ¶
func (i *ImgproxyURLData) Generate(uri string) (string, error)
Generate generates the imgproxy URL.
func (*ImgproxyURLData) Gravity ¶
func (i *ImgproxyURLData) Gravity(g GravitySetter) *ImgproxyURLData
Gravity guides imgproxy when needs to cut some parts of the image.
func (*ImgproxyURLData) Height ¶
func (i *ImgproxyURLData) Height(height int) *ImgproxyURLData
Height defines the height of the resulting image. When set to 0, imgproxy will calculate resulting height using the defined width and source aspect ratio. When set to 0 and resizing type is force, imgproxy will keep the original height.
func (*ImgproxyURLData) Preset ¶
func (i *ImgproxyURLData) Preset(presets ...string) *ImgproxyURLData
Preset defines a list of presets to be used by imgproxy.
func (*ImgproxyURLData) Quality ¶
func (i *ImgproxyURLData) Quality(quality int) *ImgproxyURLData
Quality redefines quality of the resulting image, as a percentage.
func (*ImgproxyURLData) Resize ¶
func (i *ImgproxyURLData) Resize( resizingType ResizingType, width int, height int, enlarge bool, extend bool, ) *ImgproxyURLData
Resize resizes the image.
func (*ImgproxyURLData) ResizingType ¶
func (i *ImgproxyURLData) ResizingType(resizingType ResizingType) *ImgproxyURLData
ResizingType sets the resizing type.
func (*ImgproxyURLData) SetOption ¶
func (i *ImgproxyURLData) SetOption(key, value string) *ImgproxyURLData
SetOption sets an option on the URL.
func (*ImgproxyURLData) Sharpen ¶
func (i *ImgproxyURLData) Sharpen(sigma int) *ImgproxyURLData
Sharpen applies the sharpen filter to the resulting image. The value of sigma defines the size of the mask imgproxy will use.
func (*ImgproxyURLData) Size ¶
func (i *ImgproxyURLData) Size(width int, height int, enlarge bool) *ImgproxyURLData
Size sets size option.
func (*ImgproxyURLData) Watermark ¶
func (i *ImgproxyURLData) Watermark( opacity int, position WatermarkPosition, offset *WatermarkOffset, scale int, ) *ImgproxyURLData
Watermark places a watermark on the processed image.
func (*ImgproxyURLData) Width ¶
func (i *ImgproxyURLData) Width(width int) *ImgproxyURLData
Width defines the width of the resulting image. When set to 0, imgproxy will calculate width using the defined height and source aspect ratio. When set to 0 and resizing type is force, imgproxy will keep the original width.
type OffsetGravity ¶
type OffsetGravity struct {
Type GravityEnum
XOffset int
YOffset int
}
OffsetGravity holds a gravity type and offsets coordinates.
func (OffsetGravity) GetStringOption ¶
func (o OffsetGravity) GetStringOption() string
GetStringOption gets the gravity offset value as string.
func (OffsetGravity) SetGravityOption ¶
func (o OffsetGravity) SetGravityOption(i *ImgproxyURLData) *ImgproxyURLData
SetGravityOption sets the gravity option.
type RGBColor ¶
RGBColor holds an RGB color.
func (RGBColor) SetBgOption ¶
func (rgb RGBColor) SetBgOption(i *ImgproxyURLData) *ImgproxyURLData
SetBgOption sets the background option.
type WatermarkOffset ¶
WatermarkOffset holds the watermark coordinates.
type WatermarkPosition ¶
type WatermarkPosition string
WatermarkPosition holds a watermark position option.