Documentation
¶
Overview ¶
Package jimp provides the image primitives the multimedia operations are built on, matching the Jimp library CyberChef uses.
Jimp decodes to a straight (non-premultiplied) RGBA bitmap, applies a pixel transform, then re-encodes to the source format, with GIF re-encoded as PNG. This package works on an image.NRGBA, which is also straight RGBA, so the pixel results agree exactly and lossless formats (PNG, BMP, TIFF) come out identical. JPEG is re-encoded lossily and so is an approximation.
Index ¶
- Variables
- func Blit(dst, src *image.NRGBA, x, y int)
- func BlitRect(dst, src *image.NRGBA, x, y, srcX, srcY, srcW, srcH int)
- func BlurFast(img *image.NRGBA, r int)
- func Clone(img *image.NRGBA) *image.NRGBA
- func Contain(img *image.NRGBA, w, h, alignH, alignV int, mode string) *image.NRGBA
- func Cover(img *image.NRGBA, w, h, alignH, alignV int, mode string) (*image.NRGBA, error)
- func CropExact(img *image.NRGBA, x, y, w, h int) (*image.NRGBA, error)
- func Decode(data []byte, invalidMsg string) (*image.NRGBA, string, error)
- func Gaussian(img *image.NRGBA, r float64)
- func Limit255(n int) int
- func Resize(img *image.NRGBA, wf, hf float64, mode string) *image.NRGBA
- func Scale(img *image.NRGBA, f float64, mode string) *image.NRGBA
- func ScaleToFit(img *image.NRGBA, wf, hf float64, mode string) *image.NRGBA
- func ToNRGBA(img image.Image) *image.NRGBA
- func Transform(data []byte, invalidMsg string, transform func(*image.NRGBA) *image.NRGBA) ([]byte, error)
- func TransformE(data []byte, invalidMsg string, ...) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
var ( HAlignIndex = map[string]int{"Left": 0, "Center": 1, "Right": 2} VAlignIndex = map[string]int{"Top": 0, "Middle": 1, "Bottom": 2} )
HAlignIndex/VAlignIndex map alignment labels to Jimp's 0/1/2 factors.
var BlurMaxRadius = len(blurMulTable)
BlurMaxRadius bounds BlurFast's radius: the fixed-point tables have one entry per radius, so a radius at or past their length has no entry.
var StrategyNames = map[string]string{
"Nearest Neighbour": "nearestNeighbor",
"Bilinear": "bilinearInterpolation",
"Bicubic": "bicubicInterpolation",
"Hermite": "hermiteInterpolation",
"Bezier": "bezierInterpolation",
}
StrategyNames maps cchef's option labels to Jimp's ResizeStrategy keys.
Functions ¶
func BlitRect ¶
BlitRect composites the srcW×srcH region of src at (srcX,srcY) onto dst at (x,y). Source pixels outside src read as 0, as they do in Jimp.
func BlurFast ¶
BlurFast applies Mario Klingemann's Superfast Blur (two passes) with the mulTable/shgTable fixed-point tables. r must be in [1, 256].
func Contain ¶
Contain scales img to fit within w×h and centres it (per alignment) on a transparent canvas.
func CropExact ¶
CropExact extracts the w×h region at (x,y). Returns an error if the region falls outside the source (Jimp throws a RangeError, which CyberChef surfaces).
func Decode ¶
Decode validates that data is an image, decodes it to a dense straight-RGBA bitmap, and returns the bitmap plus the source format name.
func Gaussian ¶
Gaussian applies a Gaussian blur. It reproduces Jimp's in-place scan, where the destination pixel is written inside the kernel's row loop, so later pixels convolve over already-blurred neighbours.
func ScaleToFit ¶
ScaleToFit scales img to fit within wf×hf, preserving aspect ratio.
func Transform ¶
func Transform(data []byte, invalidMsg string, transform func(*image.NRGBA) *image.NRGBA) ([]byte, error)
Transform runs the common decode -> transform -> encode pipeline shared by the Multimedia image operations. transform receives the decoded bitmap and returns the (possibly new) bitmap to encode.
Types ¶
This section is empty.