Documentation
¶
Overview ¶
Package images is a pure-Go (cgo-free) image-processing library in the style of scikit-image, built on the Go standard library's image, image/color, image/png and image/jpeg packages.
Unlike the established options in the Ruby world — ruby-vips (libvips) and RMagick (ImageMagick) — and unlike cgo-backed Go wrappers, this library has no native C dependency: it is CGO=0 and builds and runs identically on every Go target. That makes it trivially cross-compilable and embeddable (for example inside go-embedded-ruby), at the cost — for now — of the hand-tuned SIMD that libvips/ImageMagick rely on. A later phase will close that gap with SIMD kernels generated by go-asmgen across the six supported 64-bit targets. See docs/plan-images.md for the roadmap and an honest comparison with the existing pure-Go libraries (bild, disintegration/imaging).
Operations are pure functions: each takes an image and returns a freshly allocated *image.RGBA, never mutating its input. Use ToRGBA to convert an arbitrary image.Image to the *image.RGBA the operations consume, and the I/O helpers (Load, Save, Decode, Encode). Decode auto-detects eight container formats — PNG and JPEG via the standard library, and GIF, WebP, TIFF, BMP, ICO and ICNS via the shared reference registry github.com/go-gfx/gfx/codec; Encode writes PNG and JPEG.
Phase 0 implements Grayscale, Invert, Resize (nearest-neighbour, bilinear, area/box, and the high-quality bicubic and Lanczos modes, all delegated to the shared go-gfx/gfx/resample foundation), Convolve (arbitrary odd-sized kernels with edge clamping), GaussianBlur (separable), AdjustBrightness and AdjustContrast.
Phase 1 adds edge detection — Sobel (gradient magnitude) with SobelX/SobelY directional responses, the normalised Prewitt, Scharr and SobelMag operators and the Laplacian (matching skimage.filters.{prewitt,scharr,sobel,laplace}), and the full Canny detector (Gaussian, Sobel, bilinear non-maximum suppression, hysteresis); the filters BoxBlur (separable running-sum mean, matching scipy.ndimage.uniform_filter), Median (square median, matching scipy.ndimage.median_filter), and UnsharpMask/Sharpen (matching skimage.filters.unsharp_mask); the geometric transforms FlipHorizontal, FlipVertical, Rotate90/Rotate180/Rotate270 (numpy.fliplr/flipud/rot90) and Crop; the colour conversions RGBToHSV/HSVToRGB; and thresholding via OtsuThreshold/Threshold/Otsu (matching skimage.filters.threshold_otsu).
Phase 2 adds grayscale morphology over a square structuring element: Erode and Dilate (per-channel local min/max, matching scipy.ndimage.grey_erosion and grey_dilation) and the derived Open and Close. On binary 0/255 images these reduce to ordinary binary morphology.
The operations are implemented in the codec-free subpackage github.com/go-images/images/ops and forwarded here under the same names. A program that only processes pixels should import ops: importing this package links every decoder above, because each registers itself in an init function and the linker keeps what an init reaches.
docs/perf.md reports honest go-images-vs-scikit-image/SciPy benchmarks and correctness checks for the hot operations.
Index ¶
- Constants
- Variables
- func AdjustBrightness(img image.Image, delta float64) *image.RGBA
- func AdjustBrightnessRaster(src *raster.Image, delta float64) *raster.Image
- func AdjustContrast(img image.Image, factor float64) *image.RGBA
- func AdjustContrastRaster(src *raster.Image, factor float64) *raster.Image
- func AsRGBA(r *raster.Image) *image.RGBA
- func AsRaster(img *image.RGBA) *raster.Image
- func BoxBlur(img image.Image, radius int) (*image.RGBA, error)
- func BoxBlurRaster(src *raster.Image, radius int) (*raster.Image, error)
- func Canny(img image.Image, sigma, low, high float64) (*image.RGBA, error)
- func CannyRaster(src *raster.Image, sigma, low, high float64) (*raster.Image, error)
- func Close(img image.Image, radius int) (*image.RGBA, error)
- func CloseRaster(src *raster.Image, radius int) (*raster.Image, error)
- func Convolve(img image.Image, k Kernel) (*image.RGBA, error)
- func ConvolveRaster(src *raster.Image, k Kernel) (*raster.Image, error)
- func Crop(img image.Image, r image.Rectangle) (*image.RGBA, error)
- func CropRaster(src *raster.Image, r image.Rectangle) (*raster.Image, error)
- func Decode(r io.Reader) (*image.RGBA, error)
- func DecodeBest(r io.Reader, targetSize int) (*image.RGBA, error)
- func DecodeExifTranspose(r io.Reader) (*image.RGBA, error)
- func DecodePartial(r io.Reader) (*image.RGBA, int, error)
- func DecodePartialFile(path string) (*image.RGBA, int, error)
- func DecodePartialWith(r io.Reader, opt DecodeOptions) (*image.RGBA, int, error)
- func DecodeWith(r io.Reader, opt DecodeOptions) (*image.RGBA, error)
- func Deskew(img image.Image, threshold float64, opt SkewOptions) (*image.RGBA, float64, error)
- func Dilate(img image.Image, radius int) (*image.RGBA, error)
- func DilateRaster(src *raster.Image, radius int) (*raster.Image, error)
- func Encode(w io.Writer, img image.Image, format Format) error
- func Erode(img image.Image, radius int) (*image.RGBA, error)
- func ErodeRaster(src *raster.Image, radius int) (*raster.Image, error)
- func ExifTranspose(img image.Image, o Orientation) *image.RGBA
- func FlipHorizontal(img image.Image) *image.RGBA
- func FlipHorizontalRaster(src *raster.Image) *raster.Image
- func FlipVertical(img image.Image) *image.RGBA
- func FlipVerticalRaster(src *raster.Image) *raster.Image
- func GaussianBlur(img image.Image, sigma float64) (*image.RGBA, error)
- func GaussianBlurRaster(src *raster.Image, sigma float64) (*raster.Image, error)
- func Grayscale(img image.Image) *image.RGBA
- func GrayscaleRaster(src *raster.Image) *raster.Image
- func HSVToRGB(img image.Image) *image.RGBA
- func HSVToRGBRaster(src *raster.Image) *raster.Image
- func Invert(img image.Image) *image.RGBA
- func InvertRaster(src *raster.Image) *raster.Image
- func Laplacian(img image.Image) *image.RGBA
- func LaplacianRaster(src *raster.Image) *raster.Image
- func Load(path string) (*image.RGBA, error)
- func LoadExifTranspose(path string) (*image.RGBA, error)
- func Median(img image.Image, radius int) (*image.RGBA, error)
- func MedianRaster(src *raster.Image, radius int) (*raster.Image, error)
- func Open(img image.Image, radius int) (*image.RGBA, error)
- func OpenRaster(src *raster.Image, radius int) (*raster.Image, error)
- func Otsu(img image.Image) *image.RGBA
- func OtsuRaster(src *raster.Image) *raster.Image
- func OtsuThreshold(img image.Image) uint8
- func OtsuThresholdGray(g *image.Gray) uint8
- func Prewitt(img image.Image) *image.RGBA
- func PrewittRaster(src *raster.Image) *raster.Image
- func RGBToHSV(img image.Image) *image.RGBA
- func RGBToHSVRaster(src *raster.Image) *raster.Image
- func Resize(img image.Image, w, h int, mode ResizeMode) (*image.RGBA, error)
- func ResizeRaster(src *raster.Image, w, h int, mode ResizeMode) (*raster.Image, error)
- func Rotate(img image.Image, angle float64, resize bool) *image.RGBA
- func Rotate90(img image.Image) *image.RGBA
- func Rotate90Raster(src *raster.Image) *raster.Image
- func Rotate180(img image.Image) *image.RGBA
- func Rotate180Raster(src *raster.Image) *raster.Image
- func Rotate270(img image.Image) *image.RGBA
- func Rotate270Raster(src *raster.Image) *raster.Image
- func RotateGray(src *image.Gray, angle float64, fill uint8) *image.Gray
- func Save(path string, img image.Image) error
- func Scharr(img image.Image) *image.RGBA
- func ScharrRaster(src *raster.Image) *raster.Image
- func Sharpen(img image.Image) *image.RGBA
- func SharpenRaster(src *raster.Image) *raster.Image
- func SkewAngle(img image.Image, opt SkewOptions) (float64, error)
- func Sobel(img image.Image) *image.RGBA
- func SobelMag(img image.Image) *image.RGBA
- func SobelMagRaster(src *raster.Image) *raster.Image
- func SobelRaster(src *raster.Image) *raster.Image
- func SobelX(img image.Image) *image.RGBA
- func SobelXRaster(src *raster.Image) *raster.Image
- func SobelY(img image.Image) *image.RGBA
- func SobelYRaster(src *raster.Image) *raster.Image
- func Threshold(img image.Image, t uint8) *image.RGBA
- func ThresholdRaster(src *raster.Image, t uint8) *raster.Image
- func ToRGBA(img image.Image) *image.RGBA
- func Transpose(img image.Image) *image.RGBA
- func Transverse(img image.Image) *image.RGBA
- func UnsharpMask(img image.Image, radius, amount float64) (*image.RGBA, error)
- func UnsharpMaskRaster(src *raster.Image, radius, amount float64) (*raster.Image, error)
- func Warp(img image.Image, inv Affine, outW, outH int, interp Interp, mode BorderMode, ...) *image.RGBA
- type Affine
- type BorderMode
- type Component
- type ComponentOptions
- type DecodeOptions
- type Format
- type Interp
- type Kernel
- type Orientation
- type ResizeMode
- type SkewCriterion
- type SkewOptions
Constants ¶
const ( AdjacentDifference = ops.AdjacentDifference Area = ops.Area Bicubic = ops.Bicubic Bilinear = ops.Bilinear BorderConstant = ops.BorderConstant BorderEdge = ops.BorderEdge DefaultComponentMaxComponents = ops.DefaultComponentMaxComponents DefaultComponentMaxPixels = ops.DefaultComponentMaxPixels DefaultComponentMaxRuns = ops.DefaultComponentMaxRuns InterpBilinear = ops.InterpBilinear InterpNearest = ops.InterpNearest Lanczos = ops.Lanczos NearestNeighbor = ops.NearestNeighbor Variance = ops.Variance )
The constants of ops, under their names here.
Variables ¶
var ( ErrComponentLimit = ops.ErrComponentLimit ErrComponentOptions = ops.ErrComponentOptions ErrSkewAtLimit = ops.ErrSkewAtLimit ErrSkewBlank = ops.ErrSkewBlank ErrSkewEmpty = ops.ErrSkewEmpty ErrSkewOptions = ops.ErrSkewOptions )
The errors of ops, under their names here.
Functions ¶
func AdjustBrightness ¶
AdjustBrightness forwards to ops.AdjustBrightness, the codec-free implementation.
func AdjustBrightnessRaster ¶
AdjustBrightnessRaster forwards to ops.AdjustBrightnessRaster, the codec-free implementation.
func AdjustContrast ¶
AdjustContrast forwards to ops.AdjustContrast, the codec-free implementation.
func AdjustContrastRaster ¶
AdjustContrastRaster forwards to ops.AdjustContrastRaster, the codec-free implementation.
func AsRGBA ¶
AsRGBA forwards to ops.AsRGBA, the codec-free implementation.
func AsRaster ¶
AsRaster forwards to ops.AsRaster, the codec-free implementation.
func BoxBlur ¶
BoxBlur forwards to ops.BoxBlur, the codec-free implementation.
func BoxBlurRaster ¶
BoxBlurRaster forwards to ops.BoxBlurRaster, the codec-free implementation.
func CannyRaster ¶
CannyRaster forwards to ops.CannyRaster, the codec-free implementation.
func CloseRaster ¶
CloseRaster forwards to ops.CloseRaster, the codec-free implementation.
func Convolve ¶
Convolve forwards to ops.Convolve, the codec-free implementation.
func ConvolveRaster ¶
ConvolveRaster forwards to ops.ConvolveRaster, the codec-free implementation.
func CropRaster ¶
CropRaster forwards to ops.CropRaster, the codec-free implementation.
func Decode ¶
Decode reads an image from r, auto-detecting the container format from its magic bytes, and returns it converted to *image.RGBA.
Eight formats are recognised. PNG and JPEG are decoded by the standard library exactly as before — this path is byte-for-byte unchanged. The six additional formats (GIF, WebP, TIFF, BMP, ICO, ICNS) are delegated to the shared reference registry github.com/go-gfx/gfx/codec, which reimplements no decoder and hands each container to a battle-tested pure-Go (CGO-free) library. For the multi-representation containers (ICO, ICNS) the largest representation is returned; use DecodeBest to target a pixel size.
Alpha convention: every source is brought into this package under the same premultiplied-at-input convention that ToRGBA already applies to any non-*image.RGBA source. codec returns straight (non-premultiplied) alpha, so its output is routed back through ToRGBA to premultiply, keeping the whole library's decoded bytes consistent regardless of container format.
func DecodeBest ¶
DecodeBest is Decode with a target pixel size for the multi-representation containers (ICO, ICNS): among their stored representations it selects the one whose longer side is the smallest that is still at least targetSize, falling back to the largest when none reaches it. A targetSize <= 0 selects the largest, making it identical to Decode. targetSize is ignored for single-image formats. The result is a premultiplied *image.RGBA, exactly as from Decode.
func DecodeExifTranspose ¶
DecodeExifTranspose decodes an image from r and returns it already re-oriented according to its embedded EXIF orientation tag, as a premultiplied *image.RGBA. It is the auto-orienting counterpart of Decode: an image with no EXIF orientation (or a non-JPEG/TIFF source) is returned unrotated. This is the equivalent of Pillow's ImageOps.exif_transpose applied at decode time.
func DecodePartial ¶
DecodePartial reads an image from r that may still be arriving, and returns what of it is real: the picture at its full declared size, and the number of pixel rows that are COMPLETE counting from the top. Rows past the count hold whatever the image was allocated with, so a caller draws the first rows and nothing else.
The error that stopped the decode comes back with them, and is nil only when the whole image arrived — in which case the count is every row.
⛔ Every standard decoder is all-or-nothing, which for a file still arriving is the same as having nothing. Measured on a real photograph truncated at three fractions, image/jpeg, image/png and image/gif each returned a nil image and an error EVERY time, with three quarters of the picture on disk. This is why the three forks behind this call exist.
Three of the eight formats Decode recognises can answer, and each refuses some shapes of its own — an interlaced PNG or GIF, a progressive or CMYK JPEG — for reasons written where the refusal is made:
- PNG, by github.com/go-images/png
- JPEG, by github.com/go-images/jpeg
- GIF, by github.com/go-images/gif (its first frame)
The other five (WebP, TIFF, BMP, ICO, ICNS) report that they cannot. WebP is the one that could not simply be forked the same way: its frame is a VP8 keyframe, decoded as a whole rather than row by row, so there is no partial state to hand back.
⛔ One divergence from Decode, stated rather than hidden. On a COMPLETE file this returns the FORK's decode, and for a four-component JPEG that differs: the fork upsamples chroma the way libjpeg does, where the standard library repeats each sample. See github.com/go-images/jpeg. Decode's standard-library path is untouched, so anything relying on its exact bytes still gets them.
func DecodePartialFile ¶
DecodePartialFile is DecodePartial on a path, for the common case of watching a file grow on disk.
func DecodePartialWith ¶ added in v0.3.0
DecodePartialWith is DecodePartial with options; only opt.MaxPixels applies. An image whose header declares more pixels is refused with an error wrapping codec.ErrTooLarge — the forks allocate the full declared raster up front.
func DecodeWith ¶ added in v0.3.0
DecodeWith is Decode with options. An image above opt.MaxPixels is refused with an error wrapping codec.ErrTooLarge (errors.Is sees it) for every format, PNG and JPEG included; Decode and DecodeBest apply the default.
func Deskew ¶ added in v0.2.0
Deskew forwards to ops.Deskew, the codec-free implementation.
func Dilate ¶
Dilate forwards to ops.Dilate, the codec-free implementation.
func DilateRaster ¶
DilateRaster forwards to ops.DilateRaster, the codec-free implementation.
func ErodeRaster ¶
ErodeRaster forwards to ops.ErodeRaster, the codec-free implementation.
func ExifTranspose ¶
func ExifTranspose(img image.Image, o Orientation) *image.RGBA
ExifTranspose returns a copy of img re-oriented so that it displays the right way up, applying the geometric transform that the EXIF orientation o calls for. It mirrors Pillow's ImageOps.exif_transpose geometry:
1 identity 2 flip horizontal 3 rotate 180 4 flip vertical 5 transpose 6 rotate 90 CW 7 transverse 8 rotate 90 CCW
Orientations 5-8 swap the width and height. Any value outside 1-8 (including a zero Orientation) is treated as OrientationNormal and returns an unrotated RGBA copy, matching Pillow's lenient handling of an absent or invalid tag.
func FlipHorizontal ¶
FlipHorizontal forwards to ops.FlipHorizontal, the codec-free implementation.
func FlipHorizontalRaster ¶
FlipHorizontalRaster forwards to ops.FlipHorizontalRaster, the codec-free implementation.
func FlipVertical ¶
FlipVertical forwards to ops.FlipVertical, the codec-free implementation.
func FlipVerticalRaster ¶
FlipVerticalRaster forwards to ops.FlipVerticalRaster, the codec-free implementation.
func GaussianBlur ¶
GaussianBlur forwards to ops.GaussianBlur, the codec-free implementation.
func GaussianBlurRaster ¶
GaussianBlurRaster forwards to ops.GaussianBlurRaster, the codec-free implementation.
func Grayscale ¶
Grayscale forwards to ops.Grayscale, the codec-free implementation.
func GrayscaleRaster ¶
GrayscaleRaster forwards to ops.GrayscaleRaster, the codec-free implementation.
func HSVToRGB ¶
HSVToRGB forwards to ops.HSVToRGB, the codec-free implementation.
func HSVToRGBRaster ¶
HSVToRGBRaster forwards to ops.HSVToRGBRaster, the codec-free implementation.
func Invert ¶
Invert forwards to ops.Invert, the codec-free implementation.
func InvertRaster ¶
InvertRaster forwards to ops.InvertRaster, the codec-free implementation.
func Laplacian ¶
Laplacian forwards to ops.Laplacian, the codec-free implementation.
func LaplacianRaster ¶
LaplacianRaster forwards to ops.LaplacianRaster, the codec-free implementation.
func Load ¶
Load reads and decodes the image at path, returning it as *image.RGBA. The format is auto-detected from the file contents.
func LoadExifTranspose ¶
LoadExifTranspose reads the image at path and returns it re-oriented per its EXIF orientation tag, as a premultiplied *image.RGBA. It is the auto-orienting counterpart of Load.
func Median ¶
Median forwards to ops.Median, the codec-free implementation.
func MedianRaster ¶
MedianRaster forwards to ops.MedianRaster, the codec-free implementation.
func OpenRaster ¶
OpenRaster forwards to ops.OpenRaster, the codec-free implementation.
func OtsuRaster ¶
OtsuRaster forwards to ops.OtsuRaster, the codec-free implementation.
func OtsuThreshold ¶
OtsuThreshold forwards to ops.OtsuThreshold, the codec-free implementation.
func OtsuThresholdGray ¶ added in v0.5.0
OtsuThresholdGray forwards to ops.OtsuThresholdGray, the codec-free implementation.
func Prewitt ¶
Prewitt forwards to ops.Prewitt, the codec-free implementation.
func PrewittRaster ¶
PrewittRaster forwards to ops.PrewittRaster, the codec-free implementation.
func RGBToHSV ¶
RGBToHSV forwards to ops.RGBToHSV, the codec-free implementation.
func RGBToHSVRaster ¶
RGBToHSVRaster forwards to ops.RGBToHSVRaster, the codec-free implementation.
func Resize ¶
Resize forwards to ops.Resize, the codec-free implementation.
func ResizeRaster ¶
ResizeRaster forwards to ops.ResizeRaster, the codec-free implementation.
func Rotate ¶
Rotate forwards to ops.Rotate, the codec-free implementation.
func Rotate90 ¶
Rotate90 forwards to ops.Rotate90, the codec-free implementation.
func Rotate90Raster ¶
Rotate90Raster forwards to ops.Rotate90Raster, the codec-free implementation.
func Rotate180 ¶
Rotate180 forwards to ops.Rotate180, the codec-free implementation.
func Rotate180Raster ¶
Rotate180Raster forwards to ops.Rotate180Raster, the codec-free implementation.
func Rotate270 ¶
Rotate270 forwards to ops.Rotate270, the codec-free implementation.
func Rotate270Raster ¶
Rotate270Raster forwards to ops.Rotate270Raster, the codec-free implementation.
func RotateGray ¶ added in v0.4.0
RotateGray forwards to ops.RotateGray, the codec-free implementation.
func Save ¶
Save encodes img and writes it to path, choosing the format from the file extension: ".png" for PNG and ".jpg" or ".jpeg" for JPEG (case-insensitive). It returns an error for any other extension.
func Scharr ¶
Scharr forwards to ops.Scharr, the codec-free implementation.
func ScharrRaster ¶
ScharrRaster forwards to ops.ScharrRaster, the codec-free implementation.
func Sharpen ¶
Sharpen forwards to ops.Sharpen, the codec-free implementation.
func SharpenRaster ¶
SharpenRaster forwards to ops.SharpenRaster, the codec-free implementation.
func SkewAngle ¶ added in v0.2.0
func SkewAngle(img image.Image, opt SkewOptions) (float64, error)
SkewAngle forwards to ops.SkewAngle, the codec-free implementation.
func SobelMag ¶
SobelMag forwards to ops.SobelMag, the codec-free implementation.
func SobelMagRaster ¶
SobelMagRaster forwards to ops.SobelMagRaster, the codec-free implementation.
func SobelRaster ¶
SobelRaster forwards to ops.SobelRaster, the codec-free implementation.
func SobelX ¶
SobelX forwards to ops.SobelX, the codec-free implementation.
func SobelXRaster ¶
SobelXRaster forwards to ops.SobelXRaster, the codec-free implementation.
func SobelY ¶
SobelY forwards to ops.SobelY, the codec-free implementation.
func SobelYRaster ¶
SobelYRaster forwards to ops.SobelYRaster, the codec-free implementation.
func Threshold ¶
Threshold forwards to ops.Threshold, the codec-free implementation.
func ThresholdRaster ¶
ThresholdRaster forwards to ops.ThresholdRaster, the codec-free implementation.
func ToRGBA ¶
ToRGBA forwards to ops.ToRGBA, the codec-free implementation.
func Transpose ¶
Transpose forwards to ops.Transpose, the codec-free implementation.
func Transverse ¶
Transverse forwards to ops.Transverse, the codec-free implementation.
func UnsharpMask ¶
UnsharpMask forwards to ops.UnsharpMask, the codec-free implementation.
func UnsharpMaskRaster ¶
UnsharpMaskRaster forwards to ops.UnsharpMaskRaster, the codec-free implementation.
Types ¶
type Affine ¶
Affine is ops.Affine.
func Identity ¶
func Identity() Affine
Identity forwards to ops.Identity, the codec-free implementation.
func Rotation ¶
Rotation forwards to ops.Rotation, the codec-free implementation.
func Scaling ¶
Scaling forwards to ops.Scaling, the codec-free implementation.
func Translation ¶
Translation forwards to ops.Translation, the codec-free implementation.
type Component ¶ added in v0.4.0
Component is ops.Component.
func ConnectedComponents ¶ added in v0.4.0
func ConnectedComponents(mask *image.Gray, opt ComponentOptions) ([]Component, error)
ConnectedComponents forwards to ops.ConnectedComponents, the codec-free implementation.
type ComponentOptions ¶ added in v0.4.0
type ComponentOptions = ops.ComponentOptions
ComponentOptions is ops.ComponentOptions.
type DecodeOptions ¶ added in v0.3.0
type DecodeOptions struct {
// TargetSize selects among the representations of ICO and ICNS, as in
// [DecodeBest]; <= 0 selects the largest. Ignored for single-image formats.
TargetSize int
// MaxPixels refuses an image whose header declares more pixels than this,
// before anything is allocated for it. Zero (or negative) means
// codec.DefaultMaxPixels, forty million pixels.
//
// ⛔ The number it guards comes from the FILE: a PNG declaring 16000x16000 is
// a few dozen bytes and a gigabyte once decoded. A caller whose input is
// legitimately larger (a 50-megapixel camera photo) raises it; a service
// decoding files from strangers lowers it to what it actually needs.
MaxPixels int
}
DecodeOptions tunes DecodeWith, and mirrors github.com/go-gfx/gfx/codec.Options.
type Orientation ¶
type Orientation uint8
Orientation is the EXIF image-orientation tag (TIFF tag 0x0112). Its eight legal values, 1 through 8, each describe how the stored pixels must be transformed to be displayed the right way up. ExifTranspose applies the matching transform. OrientationNormal (1) is the identity.
const ( // OrientationNormal (1) needs no transform. OrientationNormal Orientation = 1 // OrientationFlipHorizontal (2) is mirrored left-to-right. OrientationFlipHorizontal Orientation = 2 // OrientationRotate180 (3) is rotated 180 degrees. OrientationRotate180 Orientation = 3 // OrientationFlipVertical (4) is mirrored top-to-bottom. OrientationFlipVertical Orientation = 4 // OrientationTranspose (5) is reflected across the main diagonal. OrientationTranspose Orientation = 5 // OrientationRotate90CW (6) needs a 90-degree clockwise rotation. OrientationRotate90CW Orientation = 6 // OrientationTransverse (7) is reflected across the anti-diagonal. OrientationTransverse Orientation = 7 // OrientationRotate90CCW (8) needs a 90-degree counter-clockwise rotation. OrientationRotate90CCW Orientation = 8 )
The eight EXIF orientation values, named for the transform each one calls for. The comment on each is the geometric operation ExifTranspose applies.
func OrientationFromExif ¶
func OrientationFromExif(data []byte) Orientation
OrientationFromExif extracts the EXIF orientation tag from an encoded image's bytes (a JPEG APP1/Exif segment, or a bare TIFF stream). It is deliberately lenient: when no EXIF block, no orientation tag, or a malformed structure is found, it returns OrientationNormal so callers can auto-orient unconditionally. A value stored outside the legal 1-8 range is also normalised to OrientationNormal.
type SkewCriterion ¶ added in v0.2.0
type SkewCriterion = ops.SkewCriterion
SkewCriterion is ops.SkewCriterion.
type SkewOptions ¶ added in v0.2.0
type SkewOptions = ops.SkewOptions
SkewOptions is ops.SkewOptions.
Directories
¶
| Path | Synopsis |
|---|---|
|
benchmarks
module
|
|
|
internal
|
|
|
kernels
Package kernels holds the per-pixel inner loops used by the public image operations.
|
Package kernels holds the per-pixel inner loops used by the public image operations. |
|
Package ops is the codec-free core of github.com/go-images/images: every pixel operation (resize, convolution, blurs, edges, morphology, colour, geometric transforms, warps, the raster facades) and nothing that decodes or encodes a file.
|
Package ops is the codec-free core of github.com/go-images/images: every pixel operation (resize, convolution, blurs, edges, morphology, colour, geometric transforms, warps, the raster facades) and nothing that decodes or encodes a file. |
