golang-png-encoding

command module
v0.0.0-...-09d3a05 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2018 License: MIT Imports: 8 Imported by: 0

README

Golang PNG Encoding

This repo test PNG compression parameters for Golang's image/png library.

Usage

You need dep and go install on your machine.

  • To download the dependencies: dep ensure
  • To build & run the program: go run main.go apercu-slack.png

Example output:

original image is 26297 bytes
decoded image: *image.Paletted, 1280x920px and 31368 bytes
resized image: *image.NRGBA, 1024x736px and 47339 bytes
indexed image: *image.Paletted, 1024x736px and 23617 bytes
compressed image: *image.NRGBA, 1024x736px and 80984 bytes
indexed image: *image.Paletted, 1024x736px and 31352 bytes

Summary

  • png.DefaultCompression gives the best result
  • original image comes with a custom color palette
  • reduced image lose the color palette
  • image reduced with nearest neighbor have a smaller size:
    • indexed image with box: 26174 bytes
    • indexed image with nearest neighbor: 23617 bytes
    • compressed image with box: 98563 bytes
    • compressed image with nearest neighbor: 80984 bytes
  • lossypng does not help to get back to the original size
  • applying the original color palette to the reduced image is the best 💜

Images

Encoding Image
Reduced Gryzzly Slack Reduced
Reduced & Indexed Grzzly Slack Indexed
Reduced & Lossy Gryzzly Slack Lossy
Reduced, Lossy & Indexed Gryzzly Slack Lossy Indexed

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL