Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugins/zt-img-zip/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
.helloagents/
.tmp-sharp-test/
.DS_Store
npm-debug.log*
24 changes: 24 additions & 0 deletions plugins/zt-img-zip/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Changelog

## v0.1.4 - 2026-06-08

- 恢复 `sharp` 图片处理管线,重新支持 JPEG、PNG、WebP、AVIF、TIFF 输出。
- 构建时将 `sharp` 生产依赖安装到 `dist/preload/node_modules`,确保 ZTools 安装插件包后可直接加载 native module。
- preload 优先从插件包内置依赖加载 `sharp`,本地开发时回退到项目根依赖。

## v0.1.3 - 2026-06-08

- 移除运行时 `sharp` 依赖,改用 Chromium 内置图片解码和 Canvas 编码,避免 ZTools 安装市场插件后找不到 native module。
- 输出格式调整为 JPEG、PNG、WebP,确保插件包解压后无需额外安装依赖即可运行。

## v0.1.2 - 2026-06-07

- 首次发布图片压缩插件。
- 支持拖入、选择、粘贴图片后批量压缩。
- 支持 JPEG、PNG、WebP、AVIF、TIFF 格式输出。
- 支持质量调节、另存为和确认后覆盖原图。
- 保存对话框默认定位到系统下载文件夹。
- 修复 PNG 默认启用调色板量化的问题,避免非预期有损输出。
- 覆盖原图时采用临时文件和原子替换,失败时清理临时文件。
- 使用图片 metadata 识别真实输入格式,减少后缀不匹配导致的错误。
- 压缩运行期间禁用移除按钮,避免结果状态残留。
21 changes: 21 additions & 0 deletions plugins/zt-img-zip/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Pidbid

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
31 changes: 31 additions & 0 deletions plugins/zt-img-zip/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 图片压缩

ZTools 图片压缩插件,用于批量压缩图片并按需转换格式。插件适合处理截图、网页素材、文档插图等常见图片文件,目标是在尽量保留观感的同时减少文件体积。

## 作用

- 支持拖入、选择或粘贴图片进行处理。
- 支持 JPEG、PNG、WebP、AVIF、TIFF 等常见格式。
- 可调节输出质量,平衡清晰度与文件大小。
- 处理完成后可另存为新文件,也可确认后覆盖原图。
- 保存时默认定位到系统下载文件夹。

## 原理

插件在 ZTools 中提供前端交互界面,图片处理能力由 preload 侧调用内置在插件包中的 `sharp` 完成。用户选择目标格式与质量后,插件先生成压缩后的临时结果;用户确认保存或覆盖时,再将结果写入指定位置。

构建脚本会把 `sharp` 生产依赖安装到 `dist/preload/node_modules`,因此发布包解压后不需要在用户机器上额外执行 `npm install`。

这种流程可以避免处理过程直接改动原始文件,也能让用户在保存前保留选择空间。

## 展示

![图片压缩插件本地测试](docs/screenshot-20260608-101203.png)

## 基础信息

- 插件名称: 图片压缩
- 包名: `zt-img-zip`
- 运行环境: ZTools 插件环境
- 核心能力: 图片压缩、JPEG/PNG/WebP 格式转换、批量处理
- 构建命令: `npm run build`
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions plugins/zt-img-zip/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/png" href="/logo.png" />
<title>图片压缩</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading
Loading