Skip to content
New issue

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

tinypng-upload一键压缩上传工具 #31

Open
muwoo opened this issue Jun 26, 2018 · 0 comments
Open

tinypng-upload一键压缩上传工具 #31

muwoo opened this issue Jun 26, 2018 · 0 comments

Comments

@muwoo
Copy link
Owner

muwoo commented Jun 26, 2018

关于 tinypng-upload

这是一个基于 electron的图片压缩上传工具,压缩过程主要通过调用tinypng提供的API完成。上传配置参考iView的文件上传配置。
因为是桌面端,所以很方便我们将图片拖拽到任务托盘进行压缩上传,极大地提升了前端的工作效率,可以让我们更专注于业务开发。

操作过程:

image

image

压缩前后体积对比(图片压缩完成已自动上传到指的CDN):

使用

1. 下载可执行文件

因为暂时没有发布到应用商店,所以需要自己编译出可执行文件:

git clone https://github.com/muwoo/tinypng-upload.git
cd tinypng-upload
npm i
npm run build

然后会在build目录下生成对应的可执行文件,运行改文件即可

2. 配置tinypng API key

因为该项目压缩过程是通过调用 tinypng API来实现的,所以我们需要去tinypng网站上注册一个API key

然后将该值粘贴到我们的配置一栏中:
image

只不过有一点限制,免费的每个月可以压缩 500 张图片。github 上也有人通过循环注册的过程,生成了多个账户API key达到近似于不限制压缩次数的目的。有兴趣也可以了解一下~

3. 配置压缩后图片上传请求

压缩完成之后,我们希望图片可以直接上传到我们公司的CDN上,tiny-png upload上传参考了iView的图片上传参数和设置:上传 upload

Property Decription Type Default
action Upload request URL, required. String -
headers Upload request header. Object {}
data Extra data with upload request. Object {}
name The key in upload request targeting to the file. String file
with-credentials Enable certification info in Cookie or not. Boolean false

灵感来源

之前在掘金上看了一篇关于electron图片上传的工具PicGo,很感谢作者提供的文章参考PicGo的star数破1000的心路历程

@muwoo muwoo changed the title 基于electron图片一键压缩上传工具tinypng-upload tinypng-upload一键压缩上传工具 Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant