imaging
A fast, dependency-light Go library for resizing, cropping, rotating, and adjusting images with zero cgo requirements.
Repository Health
Technical Analysis
Imaging is a pure-Go image processing package that wraps the standard library’s image.Image interface with a consistent, chainable API for resizing, cropping, rotating, blurring, sharpening, and color-adjusting images. Every operation accepts any type implementing image.Image and returns a uniform *image.NRGBA result, so transforms can be composed directly without manual type conversions.
Under the hood it favors direct scanline access over per-pixel interface calls and parallelizes every transform’s inner loop across available CPU cores, giving predictable performance without configuration. Because it has no cgo dependency, it’s a common choice for services that need image manipulation in statically-linked, cross-compiled Go binaries.
What You Get
- A unified
*image.NRGBAoutput type across every transform, so operations chain without manual conversions - Multiple resampling filters (Lanczos, CatmullRom, MitchellNetravali, Linear, Box, NearestNeighbor, and more) selectable per resize call
- Built-in EXIF orientation auto-correction on decode via
imaging.Open(path, imaging.AutoOrientation(true)) - Automatic multi-core parallelism in every transform, with an optional
SetMaxProcscap - Encode/decode support for JPEG, PNG, GIF, TIFF, and BMP out of the box
Common Use Cases
- Generating thumbnails for uploaded user avatars or product photos
- Server-side image resizing pipelines for CDN or static-site asset generation
- Auto-correcting phone-camera photo orientation before display
- Applying blur/sharpen/grayscale effects for image previews or watermarking
Under The Hood
Architecture The package is organized as a flat, single-namespace Go package (no internal/ or cmd/ subdirectories) where each file groups one processing concern - io.go (Decode/Open/Encode/Save plus EXIF orientation detection via a hand-rolled JPEG APP1/EXIF binary reader), resize.go (Resize/Fit/Fill/Thumbnail with precomputed per-axis weight tables in precomputeWeights), transform.go (flips/rotations/arbitrary-angle Rotate with bilinear interpolatePoint), effects.go (separable horizontal/vertical Gaussian Blur and unsharp-mask Sharpen), adjust.go (per-pixel Grayscale/Invert/AdjustContrast/AdjustBrightness/AdjustSaturation/AdjustHue via HSL conversion in utils.go), convolution.go (generic 3x3/5x5 kernel convolution), and tools.go (New/Clone/Crop/CropAnchor/Paste/Overlay compositing). All pixel access is funneled through a single scanner abstraction (scanner.go) that type-switches on the concrete image.Image implementation to read scanlines directly into a shared NRGBA byte buffer, avoiding the per-pixel At()/Set() interface-dispatch overhead the standard library normally incurs. Every transform’s inner loop runs through a shared parallel() helper in utils.go that partitions rows/columns across goroutines bounded by GOMAXPROCS (or a caller-set SetMaxProcs cap). There is no dependency injection or layering - this is a stateless, pure-function library where the same *image.NRGBA return type threads consistently through every op, letting calls chain (Resize -> Blur -> Sharpen) without conversion.
Tech Stack
Pure Go, module github.com/disintegration/imaging, with a single external dependency on golang.org/x/image (for TIFF and BMP codec support beyond the standard library’s JPEG/PNG/GIF). There is no web framework, ORM, or database involved - this is a library, not a service. CI (via Travis) runs against several Go versions across amd64 and ppc64le architectures, executing the test suite with the race detector and coverage enabled. Deployment is simply go get, since consumers import the package directly.
Code Quality
Every source file has a matching _test.go counterpart, totaling dozens of table-driven test functions using only the standard library testing package, plus a runnable godoc Example() for documentation verification. CI runs with the race detector enabled, exercising the goroutine-based parallel() paths for data races. Error handling is minimal by design - pure transform functions return values, not errors, and the small I/O surface (Decode/Open/Save) returns plain Go errors without wrapping or typed error values. No linter configuration is present in the repo; naming follows idiomatic Go conventions with doc comments on every exported symbol.
What Makes It Unique The innovation here is engineering discipline rather than novel algorithms: a scanner abstraction that type-switches to avoid interface overhead per pixel, precomputed weight tables for resampling filters to avoid repeated kernel evaluation, and a consistent *image.NRGBA return contract that lets operations chain cleanly. Compared to cgo-based bindings around native imaging libraries, this package trades some raw throughput for a pure-Go, no-cgo footprint that’s straightforward to cross-compile into static binaries - a meaningful tradeoff for services and CLIs that need portable, dependency-light image processing rather than the broadest possible feature set.
Used by 8 apps in this directory
Apache Answer
Community
Open-source Q&A platform for communities, help centers, and knowledge bases with AI assistant and plugin extensibility
CasaOS
Hosting Control Panel · File Storage
Your simple, elegant personal cloud OS for home data and apps
Crush
Developer Tools · AI Code Assistants · AI Assistants
Your terminal coding companion — wire up any LLM with LSP intelligence, MCP extensibility, and a skills system that learns your workflow.
highlight.io
Developer Tools · Analytics · Monitoring
Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.
listmonk
Marketing · Blogging
High-performance, self-hosted newsletter and mailing list manager packaged as a single binary with built-in analytics, transactional messaging, and multi-channel delivery.
memos
Note Taking
Open-source, self-hosted note-taking built for quick capture — Markdown-native, lightweight, and fully yours.
PocketBase
Databases · Ecommerce · Authentication
Open Source realtime backend in 1 file — embedded SQLite, auth, file storage, and admin UI as a single Go binary.
Vikunja
Project Management
Self-hosted task management with natural-language quick-add, multiple views, and a fully documented REST API — your tasks, your infrastructure, zero lock-in.