gitmyhub

imaging

Go ★ 5.7k updated 2y ago

Imaging is a simple image processing package for Go

A Go library for common image operations, resize, crop, rotate, flip, blur, and adjust color, with multiple resampling filters and support for JPEG, PNG, GIF, TIFF, and BMP, requiring no external dependencies.

Gosetup: easycomplexity 2/5

Imaging is a Go library for basic image manipulation. It provides a set of functions for common operations: resizing, cropping, rotating, flipping, blurring, sharpening, and adjusting brightness, contrast, saturation, hue, and gamma. You pass it any standard Go image as input and get back a new image with the changes applied. It does not modify images in place.

Resizing is the most detailed part of the package. You can resize to exact pixel dimensions, scale to fit within a bounding box while preserving the original proportions, or crop and resize to fill a target area. The library offers a range of resampling filters that trade speed for quality: NearestNeighbor is fastest and produces blocky results, while Lanczos is slower but produces sharper output better suited for photographs. The README includes comparison images showing the visual difference between filters on the same source image.

The package also handles reading images from disk and writing them back. Supported formats include JPEG, PNG, GIF, TIFF, and BMP. One practical note the README flags: JPEG photos often contain rotation metadata that Go's standard image library ignores, so resized photos can appear rotated. The package provides an AutoOrientation option on open to fix this automatically.

Installation is one command using Go's standard package tool. Documentation is hosted on pkg.go.dev. The library is intentionally lightweight. The same author maintains a separate package called gift for more advanced processing needs like color space conversions and chained multi-step pipelines.

The project is open source and written in pure Go with no external dependencies beyond the standard library.

Where it fits