Hands-on case studyAutomation & Workflows

Batch Image Compression: a Tokeny case study

Compress all image files in a directory at once while controlling file size and maintaining quality. Follow the recorded task, execution screenshots, actual files and verification notes.

By the Tokeny team · Windows · Tokeny 1.7.8 · gpt-6-sol

Prepare the inputs

Create a separate workspace in Tokeny, download and unpack the sample inputs, then select a model that supports tools. The sample uses synthetic data or the public sources named in the article.

  • input/image-1.png
  • input/image-2.png
  • input/image-3.png
Download sample inputs

Send the task to Tokeny

The original task was executed in Chinese. Copying these instructions reproduces the same task; the results below include an English report.

批量压缩 input/ 中三张演示 PNG 为 WebP,控制尺寸和质量,保留原图,生成大小对比表和总节省率。

交付文件:compression.csv、compress.py、image-1.webp、image-2.webp、image-3.webp。
验收要点:
- 三张输出可解码
- 保持宽高比
- 按实际字节统计节省率
这是使用合成演示输入或指定公开资料的真实操作案例。请先读取工作空间输入,再实际生成文件并自检。所有写入、脚本与临时服务限于当前工作空间;临时服务只监听 127.0.0.1,执行后关闭;不触达外部收件人、不发布、不付款、不更改系统设置,不调用子智能体。需要公开资料时可读取给定 URL。只启用完成任务必需的工具。另写 report.md(中文)和 report.en.md(英文),简洁、完整,包含输入、处理步骤、真实结果、检查方式和局限;失败或未验证部分如实记录,不能宣称成功。最终回复用中文列出产物、关键结果与待核实项。
排版检查:Word 主标题仅出现一次,标题为黑色且与后续正文或表格保持同页;表格的标题、表头和第一条数据保持同页,单行不要跨页拆分;Excel 表头和长文字不能被窄列截断,合理设置列宽、换行、行高;HTML 在 390px 视口不能整页横向溢出。临时网络服务请用系统分配端口(0),记录实际端口,不使用固定端口,避免并发案例互相访问。报告没有固定字数要求,不要为字数反复改写。

The recorded run used an isolated demonstration workspace. Review the commands and file paths before approving operations in your own workspace.

What actually ran

The task was submitted through the Tokeny input box. An online model read the inputs and executed tools. Three generated gradient test images are compressed. Size comparisons use the actual file bytes.

The actual Tokeny 1.7.8 session and files for Batch Image Compression. Open the image at full size.
The actual Tokeny 1.7.8 session and files for Batch Image Compression. Open the image at full size.
The actual image-1.webp file.
The actual image-1.webp file.
The actual image-2.webp file.
The actual image-2.webp file.
The actual image-3.webp file.
The actual image-3.webp file.

Results and verification

Inputs

The three PNG files in input/ were processed:

FileDimensionsOriginal bytes
input/image-1.png1600×100067,406
input/image-2.png1200×120064,101
input/image-3.png1800×90069,168

The original images were preserved unchanged in input/.

Processing

  1. compress.py read the three PNG files.
  2. Pillow encoded them as WebP with quality=82 and method=6.
  3. Original pixel dimensions were retained; no resizing was applied.
  4. Each WebP was reopened and pixel data was loaded to verify decoding and to measure actual file bytes.
  5. Per-file results and totals were written to compression.csv.

Actual results

FileWebP bytesBytes savedSaving rate
image-1.webp18,11449,29273.13%
image-2.webp16,34047,76174.51%
image-3.webp18,70450,46472.96%
Total53,158147,51773.51%

The saving rate is calculated from actual filesystem bytes: (input bytes - output bytes) / input bytes × 100%.

Checks

  • All three WebP files were reopened and loaded successfully with Pillow (decoded=True).
  • Output dimensions are 1600×1000, 1200×1200, and 1800×900 respectively, exactly matching their inputs (aspect_ratio_preserved=True).
  • compression.csv records paths, dimensions, modes, actual byte sizes, bytes saved, saving rates, encoding parameters, and check results.

Limitations

WebP was encoded with lossy quality 82, so pixel content may differ from the PNG originals. This run verified decodability, dimensions, and byte accounting, but did not perform a pixel-by-pixel similarity measurement or a subjective visual quality review. Results are specific to the current inputs and Pillow/WebP encoder environment.

Download and inspect the outputs

The archive contains the files created during this run. Use these checks when adapting the example to your own data.

  • Reconcile the reported results against the downloadable sample inputs.
  • Open the generated files and check the contents relevant to your task.
  • Review the limitations and any unverified steps in the report.
compression.csv · 1 KBcompress.py · 3 KBimage-1.webp · 18 KBimage-2.webp · 16 KBimage-3.webp · 18 KBreport.md · 2 KBreport.en.md · 2 KB
Download actual outputs

More in this category