Image information
Size
Width, Height, and Size return the image's dimensions in pixels:
img.Width() // 1920
img.Height() // 1080
img.Size() // image.Point{X: 1920, Y: 1080}For an animation, the size is the size of every frame.
Colors
ColorAt returns the color of the pixel at a position as an image.Color, with straight alpha. Outside the image, it returns a transparent color:
color := img.ColorAt(10, 20)
color.Hex() // "ff2d20"
color.A // 255Background returns the color the image uses to fill new areas, which starts as the configured background color.
Exif data
Exif returns the Exif tags of a JPEG or TIFF, keyed by section and name. Numbers are int values, and text and fractions are string values:
tags := img.Exif()
camera, _ := tags["IFD0.Model"].(string)
taken, _ := tags["EXIF.DateTimeOriginal"].(string)When the manager rotates an image by its orientation, it sets IFD0.Orientation to 1. Go's encoders don't write Exif data, so encoded files have none.
Origin
Origin describes where an image came from. Its Format is the decoded format, and its Path is the file that Open read:
origin := img.Origin()
origin.Format // image.JPEG
origin.Path // "resources/images/photo.jpg"For an image created in code, both fields are empty.
Using the standard library
An *image.Image implements the standard library's image.Image with its first frame. You may pass it to any function that accepts one, such as draw.Draw or a third-party encoder:
var std stdimage.Image = img
bounds := std.Bounds()To change pixels directly, Frames returns each frame as an *image.NRGBA with its delay. Changing a frame's pixels changes the image.