juzisang / picgo-plugin-compress

Image compression plugin for PicGo
MIT License
126 stars 31 forks source link

使用huksy+lint-staged 做代码自动提交时格式化 #17

Closed fun4wut closed 3 years ago

fun4wut commented 3 years ago

CC #16 顺便修了个typo

export function imageminCompress({ ctx, info }: CompressOptions): Promise<ImgInfo> {
  ctx.log.info('imagemin 压缩开始')
  return getImageBuffer(ctx, info.url)
    .then((buffer) => {
      ctx.log.info('imagemin 压缩完成')
      return imagemin.buffer(buffer, {
        plugins: [mozjpeg({ quality: 75, progressive: true }), upng()],
      })
    })
    .then((buffer) => {
      ctx.log.info('imagemin 压缩失败') // <=应该是压缩完成吧
      return {
        ...info,
        buffer,
      }
    })
}