Skip to content

Add plugin 图片压缩 v0.1.4#242

Open
Pidbid wants to merge 5 commits into
ZToolsCenter:mainfrom
Pidbid:plugin/zt-img-zip
Open

Add plugin 图片压缩 v0.1.4#242
Pidbid wants to merge 5 commits into
ZToolsCenter:mainfrom
Pidbid:plugin/zt-img-zip

Conversation

@Pidbid

@Pidbid Pidbid commented Jun 6, 2026

Copy link
Copy Markdown

插件信息

  • 名称: 图片压缩
  • 插件ID: zt-img-zip
  • 版本: 0.1.4
  • 描述: 使用插件包内置的 sharp 压缩图片并转换格式,支持 JPEG、PNG、WebP、AVIF、TIFF。
  • 作者: N/A
  • 类型: 新增

本次变更

  • 恢复 sharp 图片处理管线,重新支持 JPEG、PNG、WebP、AVIF、TIFF 输出。
  • 构建时将 sharp 生产依赖安装到 dist/preload/node_modules,ZTools 安装插件包后不需要再执行 npm install
  • 插件包内置 Linux x64、macOS x64、macOS arm64、Windows x64 的 sharp native 运行时依赖。
  • preload 优先从插件包内置依赖加载 sharp,本地开发时回退到项目根依赖。
  • 保留拖入、选择、粘贴图片后的批量压缩流程。
  • 支持质量调节、另存为和确认后覆盖原图。
  • 保存对话框默认定位到系统下载文件夹。

截图 / 演示

图片压缩插件本地测试

验证

  • 已在本地 ZTools 客户端安装测试包验证通过
  • 已执行 npm ci
  • 已执行 npm run build
  • 已验证 dist/preload.cjs 可从 preload/node_modules/sharp 加载 sharp@0.34.5
  • 已验证 JPEG、PNG、WebP、AVIF、TIFF 输出路径可用

自检清单

  • plugin.jsonname / title / version / description / author 字段均已检查
  • 已移除调试日志、未使用文件、敏感信息(.env、token、密钥等)
  • 本次 PR 的 diff 仅涉及 plugins/zt-img-zip/ 目录
  • 同意以仓库声明的开源协议发布此插件

此 PR 由 ztools-plugin-cli 自动管理:每次 ztools publish 在分支上追加一个 commit,PR 链接保持不变。

- Initial commit
- feat: 首次版本发布
- docs: 添加项目说明文档
- docs: 添加发布变更记录

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new image compression and format conversion plugin, zt-img-zip, which features a React-based frontend and a preload script utilizing the sharp library. The review feedback identifies several key areas for improvement: resolving a bug that forces lossy 8-bit palette compression on PNGs, implementing atomic file writes to prevent corruption during overwrites, and ensuring temporary files are cleaned up upon failure. Additionally, it is recommended to use image metadata instead of file extensions for format detection, remove the redundant preload.js file, and disable the item close button during active compression to prevent UI inconsistencies.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread plugins/zt-img-zip/preload.cjs
Comment thread plugins/zt-img-zip/preload.cjs
Comment thread plugins/zt-img-zip/preload.js Outdated
Comment thread plugins/zt-img-zip/scripts/copy-plugin-files.mjs Outdated
Comment thread plugins/zt-img-zip/preload.cjs
Comment thread plugins/zt-img-zip/preload.cjs Outdated
Comment thread plugins/zt-img-zip/src/main.tsx
@Pidbid Pidbid marked this pull request as ready for review June 6, 2026 16:40
@lzx8589561

Copy link
Copy Markdown
Contributor
image

@lzx8589561

Copy link
Copy Markdown
Contributor
image 压缩之后反而更大了呢

@Pidbid Pidbid changed the title Add plugin 图片压缩 v0.1.2 Add plugin 图片压缩 v0.1.4 Jun 8, 2026
@Pidbid

Pidbid commented Jun 8, 2026

Copy link
Copy Markdown
Author

本地测试截图如下,测试包已在本地安装验证通过。

图片压缩插件本地测试

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

Successfully merging this pull request may close these issues.

2 participants