基于 Rust 的高性能 PDF 压缩库,支持三种压缩级别
Project description
rustpdf-compress
基于 Rust 的高性能 PDF 压缩库,支持 Python 调用。
安装
pip install rustpdf-compress
使用方法
压缩文件
import rustpdf_compress
# 压缩文件,返回 (原始大小, 压缩后大小, 压缩率)
original, compressed, reduction = rustpdf_compress.compress_file(
"input.pdf",
"output.pdf",
level="recommended" # extreme / recommended / low
)
print(f"压缩了 {reduction:.1f}%")
压缩字节数据
import rustpdf_compress
with open("input.pdf", "rb") as f:
data = f.read()
compressed = rustpdf_compress.compress(data, level="recommended")
with open("output.pdf", "wb") as f:
f.write(compressed)
压缩级别
| 级别 | 说明 | 图片质量 | 缩放比例 |
|---|---|---|---|
extreme |
极限压缩 | 30% | 50% |
recommended |
推荐(默认) | 60% | 75% |
low |
低压缩 | 85% | 100% |
特性
- 🚀 基于 Rust,性能优异
- 📦 支持 Python 3.8+
- 🖥️ 支持 macOS (ARM64) 和 Linux (x86_64)
- 🔧 三种压缩级别可选
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rustpdf_compress-2026.1.0.tar.gz
(25.7 kB
view details)
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rustpdf_compress-2026.1.0.tar.gz.
File metadata
- Download URL: rustpdf_compress-2026.1.0.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
006043e2de3e958272f91fdce3af8d8f240594403036765db9ea0ace99804523
|
|
| MD5 |
4678046070f3d713e1241415d32201a3
|
|
| BLAKE2b-256 |
5a37f3b8e918198361315e96f5456bd0ed2fb63dce5bbb953898f20302fa0096
|
File details
Details for the file rustpdf_compress-2026.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rustpdf_compress-2026.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11a6cccfb2861bf3b02bf2d400e04adb0cf7265942402563ce33fa39bbaf07dd
|
|
| MD5 |
ba389cc5221afb1e26dda0238eb9541a
|
|
| BLAKE2b-256 |
97297098d8c5956aaa92479de39db2396d2193e1450c12b37f1d51c081dd958e
|
File details
Details for the file rustpdf_compress-2026.1.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: rustpdf_compress-2026.1.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
479805eca1f21b51cab84016ff283c84fcc50586a96b112eec050767893e087a
|
|
| MD5 |
3ec07d831eaf8898e6db8c4e3c9232b3
|
|
| BLAKE2b-256 |
537d879bd603c223411cafc3b6f30210ad23577f3bd50c4d5a4b68cf34d57f8a
|
File details
Details for the file rustpdf_compress-2026.1.0-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rustpdf_compress-2026.1.0-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6aece4f57db4cd378e7e19c1b0b9d1f3eda2d1d3ad8cc5ea6889a93bb42df13c
|
|
| MD5 |
ffc382514216b0f2ae99716090bd0444
|
|
| BLAKE2b-256 |
7169831f9c4910f3461fc314e2c306cbe265db1365f69e3f7dd06c57fa8d7e42
|