Skip to content

fun-tailor/tool_pdf_image_compressor

Repository files navigation

tool_pdf_image_compressor

PDF 图片压缩与页面移动工具

A PyQt6 desktop application to compress images inside PDF files (by DPI or long‑side scaling) and move pages within a PDF. Features real‑time before/after preview, per‑image custom settings, drag‑and‑drop support, and a bilingual (English/中文) interface.

自用的 压缩 pdf 图片的小工具

说明
  • 主要通过 pymupdf 这个库实现(注意 1.24以后版本,用 import pymupdf 不再是 fitz,本项目暂用 老的 fitz写法)
  • 如果需要 epub 版 压缩图片工具,可前往另一个 git 仓库(sigil 插件)
技术细节
  • pdf 不支持 .webp,所以全部转 .jpg
  • 支持设置预览
  • 支持 dpi 或 最长边(px),支持单图片自定义

Features

  • Image compression
    • Reduce file size by resizing images using maximum DPI or maximum long side (pixels)
    • Adjust JPEG quality with live preview
    • Global settings for all images + per‑image custom overrides
  • Page moving
    • Move a page range to the end of the document, with automatic ToC adjustment
  • Real‑time preview
    • Original vs. compressed side‑by‑side, fixed‑size preview panels
    • Preview updates instantly when any slider/value changes
  • Convenient workflow
    • Drag & drop PDF files onto the image list
    • Check/uncheck images to include/exclude them from processing
    • Subset fonts before saving (optional)
  • Multilingual
    • Switch between English and 中文 via the menu bar; language choice is saved automatically

Screenshot 截图

Screenshot


Installation & Usage

Prerequisites

  • Python 3.8 or higher
  • pip

1. Clone the repository

git clone https://github.com/fun-tailor/tool_pdf_image_compressor.git
cd tool_pdf_image_compressor

2. Install dependencies

pip install -r requirements.txt

requirements.txt

PyQt6
PyMuPDF
Pillow

3. Run the application

python main.py

How to use

  1. Compress images

    • Click Open PDF or drag a PDF onto the left panel.
    • Select an image from the list to see the preview.
    • Adjust global parameters (mode, DPI/side, quality) – the preview updates automatically.
    • To set custom parameters for a single image, toggle Use Custom Settings and modify the sliders/values.
    • Tick/untick images as needed.
    • Click Compress & Save As… and choose an output path.
  2. Move pages

    • Switch to the Page Move tab, open a PDF, set the page range, and click Move to End & Save As….
  3. Switch language

    • Use the Language menu in the menu bar. The choice persists across restarts.

Project Structure 项目结构

.
├── main.py            # 入口 Application entry point, menu bar, language switching
├── compress_tab.py    # Image compression tab (main UI logic)
├── move_tab.py        # Page moving tab
├── worker.py          # Background thread for PDF processing
├── utils.py           # Helper functions (compression, pixmap, etc.)
├── assets/
│   └── screenshots/
│       └── screenshot.webp
├── README.md
└── requirements.txt

About

tool to compress images inside PDF file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages