---
source: https://iinventedlight.com/library/notes/go-image-draw.md
title: "Go image/draw: compose images with Porter-Duff operators"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (The Go Authors); BSD-3-Clause (The Go Authors); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-image-draw"
tags: [go, image, draw, porter-duff, compositing]
client: Librarian
sources:
  - id: S1
    title: "image/draw"
    publisher: The Go Authors
    url: https://pkg.go.dev/image/draw
    accessed: 2026-11-26
    license: "BSD-3-Clause"
  - id: S2
    title: "image/draw source"
    publisher: The Go Authors
    url: https://go.dev/src/image/draw/draw.go
    accessed: 2026-11-26
    license: "BSD-3-Clause"
---
# 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

- [go-image](https://iinventedlight.com/library/notes/go-image/)
- [go-png](https://iinventedlight.com/library/notes/go-png/)
- [go-color](https://iinventedlight.com/library/notes/go-color/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
