img

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blur

func Blur(content []byte, blur float64, format imaging.Format) ([]byte, error)

Blur blurs an image by the given amount.

The amount is a float in the range of 0 to 1.0, where 0 is the original image and 1.0 is a fully blurred image.

The format parameter is the format of the output image. It should be the same as the format of the input image.

Example:

blurAmount := 0.5
blurFormat := imaging.JPEG
blurImage, err := Blur(imageBytes, blurAmount, blurFormat)

Parameters:

  • content: the input image as a byte slice.
  • blur: the amount to blur the image by.
  • format: the format of the output image.

Returns:

  • []byte: the blurred image as a byte slice.
  • error: an error if the image could not be decoded or encoded.

func Grayscale

func Grayscale(content []byte, format imaging.Format) ([]byte, error)

Grayscale converts an image to grayscale

Parameters: - content: The image bytes. - format: The output format.

Returns: - The grayscale image as a byte slice. - An error if the image could not be decoded or encoded.

func ImgToBase64Url

func ImgToBase64Url(filePath string) string

ImgToBase64Url converts an image file to a Base64 encoded URL string.

It reads the specified image file from disk, converts its content into a Base64 encoded string with a data URI scheme, and returns this string.

Parameters: - filePath: The path to the image file to be converted.

Returns: - string: The Base64 encoded URL string.

func Resize

func Resize(content []byte, width, height int, format imaging.Format) ([]byte, error)

Resize resizes the given image to the given width and height, and returns the resized image in the given format.

Parameters: - content: The image bytes to be resized. - width: The width to resize the image to. - height: The height to resize the image to. - format: The output format of the resized image.

Returns: - []byte: The resized image as a byte slice. - error: An error if the image could not be decoded or encoded.

func ToBase64Url

func ToBase64Url(imgBytes []byte) string

ToBase64Url converts a byte slice to a Base64 encoded URL string. It detects the MIME type of the image and prepends the appropriate data URI scheme header before encoding the byte slice to a Base64 string.

Parameters: - imgBytes: The byte slice representing the image data.

Returns: - string: The Base64 encoded URL string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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