imaging

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: BSD-3-Clause Imports: 6 Imported by: 1

Documentation

Overview

Package imaging provides just the necessary bits of github.com/disintegration/imaging to do image rotation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone(img image.Image) *image.NRGBA

Clone returns a copy of the given image.

func Crop

func Crop(img image.Image, rect image.Rectangle) *image.NRGBA

Crop cuts out a rectangular region with the specified bounds from the image and returns the cropped image.

func CropAnchor

func CropAnchor(img image.Image, width, height int, anchor Anchor) *image.NRGBA

CropAnchor cuts out a rectangular region with the specified size from the image using the specified anchor point and returns the cropped image.

func CropCenter

func CropCenter(img image.Image, width, height int) *image.NRGBA

CropCenter cuts out a rectangular region with the specified size from the center of the image and returns the cropped image.

func FlipH

func FlipH(img image.Image) *image.NRGBA

FlipH flips the image horizontally (from left to right) and returns the transformed image.

func FlipV

func FlipV(img image.Image) *image.NRGBA

FlipV flips the image vertically (from top to bottom) and returns the transformed image.

func New

func New(width, height int, fillColor color.Color) *image.NRGBA

New creates a new image with the specified width and height, and fills it with the specified color.

func Overlay

func Overlay(background, img image.Image, pos image.Point, opacity float64) *image.NRGBA

Overlay draws the img image over the background image at given position and returns the combined image. Opacity parameter is the opacity of the img image layer, used to compose the images, it must be from 0.0 to 1.0.

Usage examples:

// Draw spriteImage over backgroundImage at the given position (x=50, y=50).
dstImage := imaging.Overlay(backgroundImage, spriteImage, image.Pt(50, 50), 1.0)

// Blend two opaque images of the same size.
dstImage := imaging.Overlay(imageOne, imageTwo, image.Pt(0, 0), 0.5)

func OverlayCenter

func OverlayCenter(background, img image.Image, opacity float64) *image.NRGBA

OverlayCenter overlays the img image to the center of the background image and returns the combined image. Opacity parameter is the opacity of the img image layer, used to compose the images, it must be from 0.0 to 1.0.

func Paste

func Paste(background, img image.Image, pos image.Point) *image.NRGBA

Paste pastes the img image to the background image at the specified position and returns the combined image.

func PasteCenter

func PasteCenter(background, img image.Image) *image.NRGBA

PasteCenter pastes the img image to the center of the background image and returns the combined image.

func Rotate

func Rotate(img image.Image, angle float64, bgColor color.Color) *image.NRGBA

Rotate rotates an image by the given angle counter-clockwise . The angle parameter is the rotation angle in degrees. The bgColor parameter specifies the color of the uncovered zone after the rotation.

func Rotate180

func Rotate180(img image.Image) *image.NRGBA

Rotate180 rotates the image 180 degrees counter-clockwise and returns the transformed image.

func Rotate270

func Rotate270(img image.Image) *image.NRGBA

Rotate270 rotates the image 270 degrees counter-clockwise and returns the transformed image.

func Rotate90

func Rotate90(img image.Image) *image.NRGBA

Rotate90 rotates the image 90 degrees counter-clockwise and returns the transformed image.

func Transpose

func Transpose(img image.Image) *image.NRGBA

Transpose flips the image horizontally and rotates 90 degrees counter-clockwise.

func Transverse

func Transverse(img image.Image) *image.NRGBA

Transverse flips the image vertically and rotates 90 degrees counter-clockwise.

Types

type Anchor

type Anchor int

Anchor is the anchor point for image alignment.

const (
	Center Anchor = iota
	TopLeft
	Top
	TopRight
	Left
	Right
	BottomLeft
	Bottom
	BottomRight
)

Anchor point positions.

Jump to

Keyboard shortcuts

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