disintegration / imaging

Imaging is a simple image processing package for Go
MIT License
5.22k stars 433 forks source link

Can not decode PNG format file #125

Closed ghost closed 3 years ago

ghost commented 4 years ago

2020/07/13 10:59:39 failed to open image: image: unknown format yes no

ghost commented 4 years ago

I also try other go lib: https://github.com/h2non/filetype

It can decode and test the right file type

disintegration commented 4 years ago

Are you sure you've attached the right images? I've downloaded both of them and this code works for me:

package main

import (
    "log"

    "github.com/disintegration/imaging"
)

func main() {
    for _, filename := range []string{"test1.png", "test2.png"} {
        img, err := imaging.Open(filename)
        if err != nil {
            log.Fatal(err)
        }
        log.Printf("%s: %v", filename, img.Bounds())
    }
}
2020/07/14 02:21:38 test1.png: (0,0)-(285,304)
2020/07/14 02:21:38 test2.png: (0,0)-(289,303)

It is also worth mentioning that this package does not implement image decoding. To open PNG images it uses the standard image/png package. If you get errors while opening a valid PNG image, try decoding it using png.Decode (https://golang.org/pkg/image/png/#Decode) and if it also fails you should open an issue in the main go repository (https://github.com/golang/go).

disintegration commented 3 years ago

Closing the issue. Feel free to reopen if you have any further questions.