We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hey, i am currently try to compress png and jpg images with lilliput.
While i am uploading pngs the png file sizes are larger then before - with all kind of compression levels (1 to 9):
var EncodeOptions = map[string]map[int]int{ matchers.TypeJpeg.Extension: {lilliput.JpegQuality: 85}, matchers.TypePng.Extension: {lilliput.PngCompression: 9}, } var fileType types.Type if fileType = filetype.MatchMap(buf.Bytes(), matchers.Map{ matchers.TypeJpeg: matchers.Jpeg, matchers.TypePng: matchers.Png, }); fileType == filetype.Unknown { c.AbortWithStatusJSON(h.StatusBadRequest, http.Response(fmt.Errorf("filetype unsupported"), nil)) return } if decoder, err = lilliput.NewDecoder(buf.Bytes()); err != nil { c.AbortWithStatusJSON(h.StatusInternalServerError, http.Response(err, nil)) return } defer func() { decoder.Close() }() if header, err = decoder.Header(); err != nil { c.AbortWithStatusJSON(h.StatusInternalServerError, http.Response(err, nil)) return } var ops = lilliput.NewImageOps(8192) defer func() { ops.Close() }() var opts = &lilliput.ImageOptions{ FileType: fmt.Sprintf(".%s", fileType.Extension), Width: header.Width(), Height: header.Height(), ResizeMethod: lilliput.ImageOpsResize, NormalizeOrientation: false, EncodeOptions: EncodeOptions[fileType.Extension], } var data = make([]byte, maxSize) if data, err = ops.Transform(decoder, opts, data); err != nil { c.AbortWithStatusJSON(h.StatusInternalServerError, http.Response(err, nil)) return } log.Printf("%d:%d", len(buf.Bytes()), len(data)) // 112319:270094
Before (112 KB)
After (270 KB)
pngCompression 1
the result is 112319:408167
112319:408167
The text was updated successfully, but these errors were encountered:
the origin image is png8 to png32.. so the image is larger. so if have some func keep png8~ everything will be ok.
Sorry, something went wrong.
so there is no support for png8?
No branches or pull requests
Hey, i am currently try to compress png and jpg images with lilliput.
While i am uploading pngs the png file sizes are larger then before - with all kind of compression levels (1 to 9):
Before (112 KB)
After (270 KB)
pngCompression 1
the result is
112319:408167
The text was updated successfully, but these errors were encountered: