Coder Social home page Coder Social logo

skyfish-qc / pngtiny Goto Github PK

View Code? Open in Web Editor NEW
47.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

说明

pngtiny's People

Contributors

skyfish-qc 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

Watchers

 avatar  avatar

pngtiny's Issues

大佬我一个前端菜鸡,请教个pngtiny.js中的问题,不胜感激。

在web文件夹里的index.html中有一个方法uploadFile 这个里面的pngtiny._malloc(fsize); pngtiny._malloc(4);和最后执行了 pngtiny._free(dataptr);pngtiny._free(retdata);是做什么呢?pngtiny.js这个代码压缩的我看不懂。
我在研究wasm在前端压缩功能,探索中,但是我不太懂wasm,正好看到大佬的博客,就点进来了。你的web项目我是跑起来了,但是我不太清楚上面提到的4个方法是干啥的,主要做了啥。 希望大佬长命百岁,福如东海

Gif_writeMem 这个函数的源码能不能提供一下

unsigned char* Gif_writeMem(Gif_Stream *gfs,const Gif_CompressInfo *gcinfo,unsigned long *outsize);
gifsicle这个项目我看没有提供这个向内存写数据的函数,能否提供一下,感谢Thanks♪(・ω・)ノ

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.