gd

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package gd provides PHP's image functions over the standard library's image packages and golang.org/x/image.

The surface is the one a ported image class actually calls: decode, create, resample, draw, write. It is not all of ext/gd, and it is not everything ext/gd would let you register: a binding is here because something needs it, and the text family is absent because nothing did.

imagetypes is answered rather than omitted because ported code branches on it, but there is one decoder set behind it and it always reports the same three formats.

A GD image reaches a script as a *Image, the way fopen hands back a stream. A colour reaches it as an int packed the way libgd packs one, 0xAARRGGBB with alpha in the top byte, so a script can hold a colour in a variable and pass it to any drawing call.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(rt *runner.Runtime)

Register installs the image functions and the IMG_* and IMAGETYPE_* constants, rooted at the process working directory the way the filesystem shims are.

func RegisterRoot

func RegisterRoot(rt *runner.Runtime, dir string)

RegisterRoot installs the image functions rooted at dir. Reads resolve against it and cannot climb out; writes are additionally held to the runtime's writable_paths, matching stdlib/files.

Types

type Image

type Image struct {
	// contains filtered or unexported fields
}

Image is a GD image handle. A script never looks inside it; it holds one and passes it back to the drawing and writing functions.

func (*Image) Bounds

func (im *Image) Bounds() image.Rectangle

Bounds is the image rectangle. It is exported so a host embedding this package can inspect what a script produced.

func (*Image) Underlying

func (im *Image) Underlying() draw.Image

Underlying returns the drawable the handle wraps.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL