Closed jnlin closed 4 years ago
jnlinmacbookpro:src jnlin$ go version go version go1.14.6 darwin/amd64
package main import ( "bufio" "image/png" "os" "github.com/disintegration/imaging" ) func main() { img, err := imaging.Open("reproduce.png") if err != nil { return } imaging.Resize(img, 600, 600, imaging.Lanczos) f1, err := os.Create("output_defaultcompression.png") if err != nil { return } w1 := bufio.NewWriter(f1) imaging.Encode(w1, img, imaging.PNG, imaging.PNGCompressionLevel(png.DefaultCompression)) f2, err := os.Create("output_nocompression.png") if err != nil { return } w2 := bufio.NewWriter(f2) imaging.Encode(w2, img, imaging.PNG, imaging.PNGCompressionLevel(png.NoCompression)) }
jnlinmacbookpro:pixpic-go jnlin$ ls -al *.png -rw-r--r-- 1 jnlin staff 0 9 2 11:19 output_defaultcompression.png -rw-r--r-- 1 jnlin staff 641130 9 2 11:19 output_nocompression.png -rw-r--r-- 1 jnlin staff 3102 9 2 11:04 reproduce.png
The original PNG file is attached as ZIP files to avoid processing by GitHub. image.zip
Correct output PNG file
See https://github.com/disintegration/imaging/issues/75
It works, thanks!
Go version
Reproducible Code Below:
The result:
The original PNG file is attached as ZIP files to avoid processing by GitHub. image.zip
Expected Result:
Correct output PNG file