基于 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-0.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-0.1.0.tar.gz.
File metadata
- Download URL: rustpdf_compress-0.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 |
7cc6d08a9501a7664f79eafe7d10ef331e2a94582136d3d388bc80238c2a1513
|
|
| MD5 |
1f37ea514e93384fcd7bd745e52a3eb3
|
|
| BLAKE2b-256 |
3cc93bd263dfe8f013b62dd0209c44b9f4c57160f52c20345491e729d1910d00
|
File details
Details for the file rustpdf_compress-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rustpdf_compress-0.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 |
8bcd303e85a083f2c238b86d7c49d0a011519685ce49ed91e531f5ab14fbc00f
|
|
| MD5 |
446802676a40d5437e23efafa6da1703
|
|
| BLAKE2b-256 |
fc92b4d56c20b76aacd602eb8207f908057781719b5c1064d27559ee21672d44
|
File details
Details for the file rustpdf_compress-0.1.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: rustpdf_compress-0.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 |
7d6110e923bd4181415619e6415ff2842675d76631c3cb3e9492c06091c94d60
|
|
| MD5 |
5a6f7cb3997b1e26198d3c01a4d6462d
|
|
| BLAKE2b-256 |
5febb84c391b87d3ad4ff0fc9b8a427eef16d05832b3cec36adf3264a34de133
|
File details
Details for the file rustpdf_compress-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rustpdf_compress-0.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 |
8f27d27dd08ee71d24dd459736f76edabb9740f0d0331eba3cc58df7795dabe8
|
|
| MD5 |
93167af712177728732c0bccf72225ff
|
|
| BLAKE2b-256 |
07fa929dc57e394a515f8fc14e38f9554330596869c9778d50b3481dbaf2d930
|