Skip to content

mcnaveen/go-url-blurhash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go URL Blurhash

🦄 Simple Go utility to generate blurhash from Image URL or local file

Go Version License

📦 Requirements

  • Go 1.19 or higher

✨ Installation

go get github.com/mcnaveen/go-url-blurhash

💡 Usage Example

package main

import (
    "fmt"
    "github.com/mcnaveen/go-url-blurhash/blurhash"
)

func main() {
    // Generate blurhash from URL
    output, err := blurhash.BlurhashFromURL("https://i.imgur.com/NhfEdg2.png", blurhash.Options{
        Size: 32, // Optional, defaults to 32
    })
    if err != nil {
        panic(err)
    }
    fmt.Printf("%+v\n", output)

    // Generate blurhash from local file
    localOutput, err := blurhash.BlurhashFromURL("./image.jpg", blurhash.Options{
        Size:    32,
        Offline: true,
    })
    if err != nil {
        panic(err)
    }
    fmt.Printf("%+v\n", localOutput)
}

✅ Example Output

{
    "Encoded": "UnR.*,kW.TnPt7WBocozpJV@nMkWadofWCV@",
    "Width": 600,
    "Height": 600
}

Optional Parameters

The Options struct accepts the following parameters:

  • Size: Image resize dimensions (default: 32)
  • Offline: Boolean to process local files instead of URLs (default: false)
options := blurhash.Options{
    Size:    64,    // Optional: Custom size
    Offline: true,  // Optional: Process local files
}

💚 Message

I hope you find this useful. If you have any questions, please create an issue.

About

Simple Go utility to generate blurhash from Image URL or local file

Topics

Resources

License

Stars

Watchers

Forks

Languages