Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
imageresizetool
Advanced tools
Readme
npm install
gulp
var file = document.getElementById('demo').files[0];
imageResizeTool.fileResizetoFile(file,0.6,function(res){
//回调中的res是一个压缩后的Blob类型(可以当做File类型看待)文件;
console.log(res);
//做出你要上传的操作;
})
使用过多的会调函数代码看上去会不优雅,如下:
var canvas = imageResizeTool.imagetoCanvas(img);
imageResizeTool.canvasResizetoFile(canvas,quality,file=>{
imageResizeTool.filetoDataURL(file,data=>{
imageResizeTool.dataURLtoImage(data,img=>{
//做相应的操作
})
})
})
这时候可以引入 resize.promise.js
文件,以便使用 Promise
进行链式调用,如下:
imageResizeTool.imagetoCanvas(img)
.then(canvas => imageResizeTool.canvasResizetoFile(canvas,quality))
.then(file => imageResizeTool.filetoDataURL(file))
.then(data => imageResizeTool.dataURLtoImage(data))
.then(img => {
//做相应的操作
})
})
FAQs
简单的易用的js压缩图片方法
The npm package imageresizetool receives a total of 3 weekly downloads. As such, imageresizetool popularity was classified as not popular.
We found that imageresizetool demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.