Code Monkey home page Code Monkey logo

go-blurhash's People

Contributors

buckket avatar michielbuddingh avatar xkcdstickfigure avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-blurhash's Issues

Using the exact same parameters as blurha.sh produces different results

Hello! I am using the library and have been for a while, but I've noticed for a while that it produces different (and arguably worse) results than the website implementation at blurha.sh

Please see my reference images. Any idea what could be going wrong?

Here is the generated blur hash and the difference in results:
LTIXH#ai5XRo0xRRnzR-4.M}-$V[

Screenshot 2023-06-14 at 11 14 18 PM Screenshot 2023-06-14 at 11 14 26 PM Screenshot 2023-06-14 at 11 14 34 PM

Pointer to image.Image interface

This library has the Encode API take in a pointer to image.Image (*image.Image) instead of either the interface itself (which has an underlying value of a pointer) or a concrete struct such as *image.NRGBA. This is usually a bad idea.

The lines that use this "pointer to interface" seem to only dereference the interface and not change it:

https://github.com/buckket/go-blurhash/blob/master/encode.go#L110-L111

height := (*rgba).Bounds().Max.Y
width := (*rgba).Bounds().Max.X

https://github.com/buckket/go-blurhash/blob/master/encode.go#L131

rt, gt, bt, _ := (*rgba).At(x, y).RGBA()

Panic on specific broken image [bug]

The library panics in case of uploading a broken image.

Relates to disintegration/imaging#165

Minimal reproducible example

  • poc.tiff by @pic4xiu
  • main.go
    package main
    
    import (
        "fmt"
        "log"
        "os"
    
        "github.com/buckket/go-blurhash"
        "golang.org/x/image/tiff"
    )
    
    func main() {
        imageFile, err := os.Open("poc.tiff")
        if err != nil {
    	    log.Fatal(err)
        }
    
        loadedImage, err := tiff.Decode(imageFile)
        if err != nil {
    	    log.Fatal(err)
        }
    
        str, err := blurhash.Encode(4, 3, loadedImage) // Panic.
        if err != nil {
    	    log.Fatal(err)
        }
    
        fmt.Printf("Hash: %s\n", str)
    }

Panic

panic: runtime error: index out of range [70] with length 65

goroutine 1 [running]:
image.(*Paletted).At(0xc000061d68?, 0x48a050?, 0x101c000061d98?)
        /usr/local/go/src/image/image.go:1159 +0x9a
github.com/buckket/go-blurhash.multiplyBasisFunction({0x4dfb20, 0xc00002c2a0}, {0xc00014c000, 0x24, 0x1?}, 0x4, 0x3)
        .../poc-blurhash/vendor/github.com/buckket/go-blurhash/encode.go:131 +0x207
github.com/buckket/go-blurhash.Encode(0x4, 0x3, {0x4dfb20, 0xc00002c2a0})
        .../poc-blurhash/vendor/github.com/buckket/go-blurhash/encode.go:63 +0x22e
main.main()
        .../poc-blurhash/main.go:23 +0xc9
exit status 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.