Closed ghost closed 3 years ago
I also try other go lib: https://github.com/h2non/filetype
It can decode and test the right file type
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).
Closing the issue. Feel free to reopen if you have any further questions.
2020/07/13 10:59:39 failed to open image: image: unknown format