Coder Social home page Coder Social logo

skyfish-qc / pngtiny Goto Github PK

View Code? Open in Web Editor NEW
48.0 2.0 12.0 2.66 MB

一个js压缩图片的工具。功能用C编写,利用了libimagequant和libpng库,读取png图片进行压缩,然后导出wasm在页面运行,从而使得可以直接在页面压缩图片,不需要上传到服务器处理。

License: MIT License

JavaScript 4.93% Batchfile 0.06% C 93.15% CMake 0.57% CSS 0.46% HTML 0.83%
wasm webassembly png tiny pngtiny optimize gif jpg

pngtiny's Introduction

#js版png压缩工具

  • 2021.10.14 添加jpg图片压缩
  • 2021.10.19 添加GIF图片压缩
  • 2022.01.06 添加demo地址

##新加函数代码

unsigned char *
Gif_writeMem(Gif_Stream *gfs, const Gif_CompressInfo* gcinfo, unsigned long * outsize) {
    Gif_Writer grr;
    int ok = gif_writer_init(&grr, NULL, gcinfo)&& write_gif(gfs, &grr);
    unsigned char* buf=NULL;
    if(ok) {
        buf = malloc(grr.pos);
        memcpy(buf,grr.v, grr.pos);
        memcpy(outsize,&grr.pos,sizeof(unsigned long));
    }
    gif_writer_cleanup(&grr);
    return buf;
}

使用

部署web文件夹到服务器访问即可(需要在支持webassembly的浏览器访问,比如Chrome,edge)

可以访问 demo

说明

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.