Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Components ¶
Components decodes and returns the number of x and y components in the given Blurhash.
Example ¶
x, y, err := blurhash.Components("LFE.@D9F01_2%L%MIVD*9Goe-;WB") if err != nil { // Handle errors } fmt.Printf("xComponents: %d, yComponents: %d", x, y)
Output: xComponents: 4, yComponents: 3
func Decode ¶
Decode generates an image of the given Blurhash with a size of width and height. Punch is a multiplier that adjusts the contrast of the resulting image.
Example ¶
img, err := blurhash.Decode("LFE.@D9F01_2%L%MIVD*9Goe-;WB", 204, 204, 1) if err != nil { // Handling errors } f, _ := os.Create("test_blur.png") _ = png.Encode(f, img)
Output:
func Encode ¶
Encode calculates the Blurhash for an image using the given x and y component counts. The x and y components have to be between 1 and 9 respectively. The image must be of image.Image type.
Example ¶
imageFile, _ := os.Open("test.png") loadedImage, err := png.Decode(imageFile) str, err := blurhash.Encode(4, 3, &loadedImage) if err != nil { // Handle errors } fmt.Printf("Hash: %s", str)
Output: Hash: LFE.@D9F01_2%L%MIVD*9Goe-;WB
Types ¶
type EncodingError ¶
type EncodingError string
An EncodingError represents an error that occurred during the encoding of the given value. This most likely means that your input image is invalid and can not be processed.
func (EncodingError) Error ¶
func (e EncodingError) Error() string
type InvalidHashError ¶
type InvalidHashError string
An InvalidHashError occurs when the given hash is either too short or the length does not match its size flag.
func (InvalidHashError) Error ¶
func (e InvalidHashError) Error() string
type InvalidParameterError ¶
type InvalidParameterError struct {
// contains filtered or unexported fields
}
An InvalidParameterError occurs when an invalid argument is passed to either the Decode or Encode function.
func (InvalidParameterError) Error ¶
func (e InvalidParameterError) Error() string