📖
ImGo Documentation
  • GETTING STARTED
    • Introduction
    • Coordinate Axis
    • Supported Formats
    • Update Logs
  • Usage
    • Usage Overview
    • Errors handling
  • API
    • Blur
    • Bounds
    • Canvas
    • Circle
    • Color2Hex
    • Crop
    • Ellipse
    • Extension
    • Filesize
    • Flip
    • GaussianBlur
    • Grayscale
    • Height
    • HttpHandler
    • Insert
    • Load
    • LoadFromBase64
    • LoadFromFile
    • LoadFromImage
    • LoadFromImgo
    • LoadFromPath
    • LoadFromUrl
    • Line
    • MainColor
    • Mimetype
    • Mosaic
    • PickColor
    • Pixel
    • Pixelate
    • RadiusBorder
    • Rectangle
    • Resize
    • Rotate
    • Save
    • String
    • Text
    • Thumbnail
    • ToBase64
    • ToImage
    • Width
Powered by GitBook
On this page
  • Parameters
  • Return Values
  • Examples
  1. API

Grayscale

Convert the image to grayscale in 8-bit color.

Parameters

None

Return Values

The instance of *imgo.Image .

Examples

package main

import (
    "github.com/fishtailstudio/imgo"
)

func main() {
    imgo.Load("gopher.png").
        Grayscale().
        Save("out.png")
}

Continue editing after converting to grayscale:

package main

import (
    "github.com/fishtailstudio/imgo"
)

func main() {
    imgo.Load("gopher.png").
        Grayscale().
        Resize(100, 0).
        Save("out.png")
}

Inserting an image converted to grayscale onto another image does not affect the color space of the other image. The following example still outputs an RGBA image.

package main

import (
    "github.com/fishtailstudio/imgo"
    "golang.org/x/image/colornames"
)

func main() {
    gopher := imgo.Load("gopher.png").Grayscale()
    imgo.Canvas(300, 300, colornames.Blueviolet).
        Insert(gopher, 50, 50).
        Save("out.png")
}
PreviousGaussianBlurNextHeight

Last updated 2 years ago