← All notes

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

Sources

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

Permanent ID: iil:note:437tfcg8

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.},
}

Markdown

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.

All artifact files (JSON index)

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.