
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
img-master
Advanced tools
img-master是一个多功能无限制的图像批处理工具,提供压缩、分组、标记和变换四大批处理功能
npm i -g img-master
安装失败
img-master某些功能基于sharp,所以在安装过程中可能会失败或报错,请通过以下步骤解围。
npm config set registry https://registry.npm.taobao.org/npm config set disturl https://npm.taobao.org/mirrors/node/npm config set sharp_binary_host https://npm.taobao.org/mirrors/sharp/npm config set sharp_libvips_binary_host https://npm.taobao.org/mirrors/sharp-libvips/npm cache clean -f(曾经安装失败才执行)npm i -g img-master若是多账户电脑(公司环境),请切换到管理员账号下执行npm i -g img-master重新安装
若有兴趣了解某些模块因NPM镜像问题而安装不上的解围思路,可查看笔者这篇《聊聊NPM镜像那些险象环生的坑》,相信会对你有很大的帮助。
| 命令 | 缩写 | 功能 | 描述 |
|---|---|---|---|
img-master compress | img-master c | 压缩图像 | 基于TinyJPG或TinyPNG进行压缩 |
img-master group | img-master g | 分组图像 | 按照图像尺寸、类型或体积进行分组 |
img-master mark | img-master m | 标记图像 | 基于Sharp进行标记,提供交互式问答调用 |
img-master transform | img-master t | 变换图像 | 基于Sharp进行变换,提供多配置链式调用 |
JPG和PNG的图像cd my-image,再根据需求执行以上命令图像压缩
https://tinyjpg.com或https://tinypng.com压缩图像会有20张的数量限制img-master c基于以上两个网站进行压缩,但是通过随机修改请求头的X-Forwarded-For绕过其数量限制图像变换
类似Gulp的流处理| 配置 | 功能 | 格式([]表示可选) | 描述 |
|---|---|---|---|
--blur | 模糊 | 0.3~1000 | 不设置则不生效 |
--extract | 裁剪 | left,top,width,height | 不设置则不生效 |
--flip | 平翻 | true | 不设置则不生效 |
--flop | 对翻 | true | 不设置则不生效 |
--format | 格式 | jpg或png | 不设置则使用图像原来的类型 |
--grayscale | 灰度 | true | 不设置则不生效 |
--negate | 负片 | true | 不设置则不生效 |
--normalise | 对比 | true | 不设置则不生效 |
--resize | 尺寸 | width,height[,fit] | 若其中一方为0则自动缩放以匹配另一方 不设置则不生效 |
--rotate | 旋转 | angle[,bgcolor] | 不设置则不生效 |
--sharpen | 锐化 | true或[sigama,flat,jagged] | true表示执行快速温和的锐化输出sigama在 0.3~1000间,其余参数必须>0不设置则不生效 |
cover:裁剪以适应在指定尺寸中contain:嵌入在指定尺寸中fill:忽略宽高比,拉伸以填满在指定尺寸中inside:保留宽高比,将尺寸调整到尽可能大,同时确保其尺寸小于或等于指定尺寸outside:保留宽高比,将尺寸调整到尽可能小,同时确保其尺寸大于或等于指定尺寸transparent:透明,需配合--format png使用HEX:16进制色值,可选#xyz或#uvwxyzRGB:RGB色值,rgba(r,g,b)RGBA:RGBA色值:rgba(r,g,b,a)注意事项
--opt [val],不然会报错导致无法执行,,不能使用空格压缩图像
#compressed-dist##compressed-dist#下#compressed-dist#再生成新的#compressed-dist#,注意保存压缩过的图像分组图像
#grouped-dist##grouped-dist#下#grouped-dist#再生成新的#grouped-dist#,注意保存分组过的图像标记图像
#marked-dist##marked-dist#下#marked-dist#再生成新的#marked-dist#,注意保存标记过的图像变换图像
#transformed-dist##transformed-dist#下#transformed-dist#再生成新的#transformed-dist#,注意保存变换过的图像所有命令作用一次以下文件夹的图像

压缩图像
img-master c


分组图像
img-master g


标记图像
img-master m


变换图像
img-master t --resize 300,0 --extract 50,50,100,100 --rotate 200,#3c9 --blur 5 --format png


相同配置但不同顺序也可能导致生成图像不同
MIT © Joway Young
若觉得img-master对你有帮助,可在Issue上提出你的宝贵建议,笔者会认真阅读并整合你的建议。喜欢img-master的请给一个Star,或Fork本项目到自己的Github上,根据自身需求定制功能。
关注公众号IQ前端,一个专注于CSS/JS开发技巧的前端公众号,更多前端小干货等着你喔

FAQs
An image batch processing tool with multifunctional and unlimited
We found that img-master 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.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.