Documentation
¶
Index ¶
- func Blur(content []byte, blur float64, format imaging.Format) ([]byte, error)
- func Grayscale(content []byte, format imaging.Format) ([]byte, error)
- func ImgToBase64Url(filePath string) string
- func Resize(content []byte, width, height int, format imaging.Format) ([]byte, error)
- func ToBase64Url(imgBytes []byte) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Blur ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.