Giter VIP home page Giter VIP logo

pngquantjs's Introduction

Pngquant.js

Pngquant.js is a port of pngquant lib in js, made possible by emscripten which compiles LLVM bit code generated from c/c++ directly to javascript. Pngquant js can compress png images right in your browser without any server requirements. This can open a wide array of possibilities of what can be achieved on a browser, with clients compressing the static assets on their device itself, saving precious bandwidth.

Build

This version of pngquantjs is built using v2.8.0 of pngquant. Original configure script needs to be patched in order to be used by emscripten. Patched version of this file is present in the deps folder in this directory. Additionally, patch file for configure script is also present in the repository in order to create a fresh copy. Build script assumes that emscripten is already built and available in the system path. Once this is ensured, just run ./build.sh which will initiate build process and pngquant.js will be available in dist folder. This file can be easily compressed using uglify.js. I haven't included the command to use uglify.js in the build script (planning to do so soon), but a minified version of pngquant.js is included in the demo folder. Since the process of setting up emscripten is tedious and may pollute the global namespace, I have created a docker image which comes preinstalled with emscripten and all environments initialized. It's available at this link and can be used by issuing docker pull psych0der/emscripten command. I would recommend using docker image since it greatly simplifies working with emscripten without thinking about any installation issue.

Demo

https://psych0der.github.io/pngquantjs/

License

pngquantjs's People

Contributors

psych0der avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pngquantjs's Issues

congrats

Really nice work, I'll try to use it, I currently optimize png/jpg on server, but it would be better on browser. (here's an online demo and server-side code)

Do you plan to also try to emscripten mozjpeg?

Also something's weird, if you open the output image blob in another tab, you see ‰PNG � ��� IHDR���€���8������ýÜp��� pHYs��.#��.#.... but if you download it, it's readable

^ fixed in #4

Color difference between pngquant 2.8 and pngquantjs demo

It seems the output of pngquantjs has a slight diffence in color compared to the original image(or the output from the binary version).

Tested with a solid color png.

comppure
Original

comppure-fs8
Compressed with pngquant 2.8 on macos

comppure-js
Compressed with pngquantjs

#FF99D5 -> #FF9FD3

Configure script?

What's the problem with the configure script? Can I make it work without the patch?

Default quality range

Thanks for making it work!

When I've tried it, the quality range I got was 30-35.

I recommend always setting max quality to 100, since filesize reduction from quality < 100 isn't very large, but has a potential to introduce visible degradation.

You could even use 0-100 range by default, which would mean everything is always converted to 256 colors, which is OK for pngquant-only tool without a fallback to another format.

GPL?

The original pngquant source code is licensed with GPL, so I'm wondering if I could use this project without applying GPL to my application.

Shouldn't this library's license be GPL?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.