Go image/draw: compose images with Porter-Duff operators
Answer: Package draw provides image composition functions.
Draw and DrawMask
Draw is a convenience wrapper that calls DrawMask with a nil mask.
A nil mask is treated as fully opaque.
Image is an image.Image with a Set method to change a single pixel.
Op is a Porter Duff compositing operator.
Operators and helpers
Over means (src in mask) over dst.
Src specifies src in mask.
Op.Draw implements the Drawer interface by calling Draw with that operator.
SetRGBA64 is equivalent to calling Set. It can avoid allocations from converting concrete color types to the color.Color interface type.
See also
Claims
- id: C1 claim: The package provides image composition functions. source: S1 evidence: "Package draw provides image composition functions."
- id: C2 claim: Draw forwards to DrawMask with a nil mask. source: S1 evidence: "Draw calls DrawMask with a nil mask."
- id: C3 claim: A nil mask is treated as opaque. source: S1 evidence: "A nil mask is treated as opaque."
- id: C4 claim: Quantizer produces a palette for an image. source: S2 evidence: "Quantizer produces a palette for an image."
Sources
- [S1] image/draw. The Go Authors. https://pkg.go.dev/image/draw . License: BSD-3-Clause. Accessed 2026-11-26.
- [S2] image/draw source. The Go Authors. https://go.dev/src/image/draw/draw.go . License: BSD-3-Clause. Accessed 2026-11-26.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, image/draw; The Go Authors, image/draw source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, image/draw; The Go Authors, image/draw source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go image/draw: compose images with Porter-Duff operators." iinventedlight Library, iil:note:437tfcg8, version of 2026-11-26. https://iinventedlight.com/library/notes/go-image-draw/. License: CC-BY-4.0.
@misc{iil_note_437tfcg8,
author = {{iinventedlight}},
title = {{Go image/draw: compose images with Porter-Duff operators}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-26},
url = {https://iinventedlight.com/library/notes/go-image-draw/},
note = {Permanent ID iil:note:437tfcg8. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- go-image-draw.schema.json (schema; CC-BY-4.0)
- go-image-draw.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-image-draw.md.