picgo-plugin-compress-next

1.5.2 • Public • Published

中文 <-| English

🍴 分支

这是 picgo-plugin-compress-webp-lossless 的一个分支,同时它又是 picgo-plugin-compress 的分支

🚀 部署使用

PicGo-Core 安装

  • 安装 picgo add compress-next
  • 选择使用 picgo use transformer
  • 参数配置 picgo config plugin compress-next

PicGo-Gui 安装

  • 打开详细窗口 > 插件设置 > 搜索 compress-next 即可安装,点击模块右下角配置参数
  • 或者,进入 picgo 目录 npm i picgo-plugin-compress-next
  • 离线安装参考这里

参数配置

  • Compress Type (过段时间会制作详细对比分析表):
    • tinypng: 无损压缩,需要上传到 tinypng
    • imagemin: 图片压缩不改变后缀名,支持 jpegpng,使用 mozjpegupng
    • imagemin-webp: 本地压缩为 webp 注意:有些图床(比如 sm.ms)不支持 webp 图片格式,会上传失败
    • webp-converter: 同上
  • Gif Compress Type:
  • Auto Refresh TinyPng Key Across Months:
    • yes: 检测到跨月(与上次使用时年月不同)则自动刷新 TinyPng API Key 的状态
    • no: 不检测,但是仍然记录年月
  • TinyPng API Key:
    • developers 中申请
    • 逗号,隔开,可使用多个 Key 叠加使用次数
压缩参数配置

参考 option.example.json

⚗️ 背景

picgo-plugin-compress 已经许久没有更新了,关键是在 PicGo 底层上传库从 request 迁移至 axios ,参考 PicGo/PicGo-Core#65 ,导致 TinyPng 不可用。似乎最后一个可用版本是PicGo v2.3.0

幸运的是我发现了 picgo-plugin-compress-webp-lossless ,但是其只上传了 v1.0.1 ,其实现仍然是 picgo-plugin-compress 的旧实现,但是其代码更新到了 v1.1.0 ,可惜的是使用 ES 重构后无法兼容 PicGo ,并且仍旧存在些许问题。

于是便有了 picgo-plugin-compress-next 的诞生 🎉

💥 对比

compress-next compress
TinyPng version >= 2.3.1 🟡 最高 version 2.3.0
多个 Key 叠加使用
使用逗号分隔,自动清除空白符
多个 Key 叠加使用
严格使用逗号,不可有空白符
TinyPngWeb 已弃用
抛出异常并提示配置 Key
TinyPngWeb 已不可用
抛出空白异常 只能查看日志
网页返回 404 或则 413
出现无效 Key,自动跳过
标记并不再访问,除非手动刷新
出现无效 Key,抛出空白异常
查看日志,网页返回 404
支持手动刷新有效 Key
支持手动刷新所有 Key
可设置是否跨月份自动刷新 Key
若有效 Key 达到使用次数,则不再访问
需要删除相应配置文件,才可重置
imagemin mozjpeg & upng:
可以自行配置压缩参数
🟡 mozjpeg & upng:
支持本地有损压缩
imagemin-webp:
可以自行配置压缩参数
🟡 imagemin-webp:
支持本地有损转换为 webp
imagemin-gif2webp:
gif 转换为 webp,可自行配置参数
不支持 gif 转 webp
准备了多套压缩配置参数,可自行配置 固定的提前设置好的参数
webp-converter jpeg, png, webp 压缩为 webp
可自行配置参数
不支持使用 webp-converter
gif 压缩为 webp,可自行配置参数

🎉 功能

  • [x] 支持多个 Key 叠加使用
  • [x] 支持 PicGo >= v2.3.1TinyPng 压缩
  • [x] 禁用 TinyPngWeb 并抛出异常
  • [x] 对错误的 Key 处理并跳过
  • [x] 处理 Key 的刷新问题:
    • [x] 刷新有效 Key
    • [x] 刷新所有 Key
    • [x] 跨越份自动刷新有效 Key
  • [x] 加入 webp-converter
  • [x] 加入 gift 2 webp 的能力
    • [x] 使用 webp-convertergwebp
    • [x] imagemin-gif2webp
  • [x] 可以根据自身需求配置压缩的具体参数
    • [x] imagemin-upng
    • [x] imagemin-mozjpeg
    • [x] imagemin-webp
    • [x] imagemin-gif2webp
    • [x] webp-converter-cwebp
    • [x] webp-converter-gwebp

压缩比较

TODO ... ...

报告问题

你可以直接点击这里创建一个问题

/picgo-plugin-compress-next/

    Package Sidebar

    Install

    npm i picgo-plugin-compress-next

    Weekly Downloads

    13

    Version

    1.5.2

    License

    MIT

    Unpacked Size

    59.4 kB

    Total Files

    23

    Last publish

    Collaborators

    • imlzl