cli tool wrapper for manipulating multiple pdfs file in parallel using ghostscript (compressing, convert to pdfa, etc.)
Project description
gs_batch
gs_batch
is a command-line tool for batch (parallel) processing PDF files using Ghostscript, applying the same set of gs options to all files specified while taking care of file renaming.
It offers convenient default settings for compression, PDF/A conversion, and you can also apply any custom Ghostscript options.
Features
- Batch process multiple PDF files
- Compress PDFs with various quality settings
- Convert PDFs to PDF/A format
- Apply custom Ghostscript options
- Multi-threaded processing for improved performance
- Progress tracking with tqdm
- Automatic file renaming with customizable prefixes and suffixes
- Option to keep either the smaller file or the new file after processing
- Cross-platform support (Windows, Linux, macOS)
Installation
To install gs_batch
, make sure you have Python 3.12+ and pipx[^1] installed, then run:
[^1]:pipx
will let you install the package in a virtual environment, but the commands will be available from the command line
pipx install git+https://github.com/kompre/gs-batch.git
Note: This tool requires Ghostscript to be installed on your system. Make sure you have Ghostscript installed and accessible from the command line.
Usage
Basic usage:
gs_batch
and the its alias gsb
will be available from the command line.
gs_batch [OPTIONS] FILES...
Options:
--options TEXT
: Arbitrary Ghostscript options and switches.--compress TEXT
: Compression quality level (e.g., /screen, /ebook, /printer, /prepress) (default: /ebook).--pdfa INTEGER
: PDF/A version (1 for PDF/A-1, 2 for PDF/A-2, 3 for PDF/A-3; default: 2).--prefix TEXT
: Prefix to add to the output file name.--suffix TEXT
: Suffix to add to the output file name before the extension.--keep_smaller / --keep_new
: Keep the smaller file between old and new (default: keep smaller).
Examples
- Compress multiple PDF files using ebook quality:
gs_batch --compress=/ebook file1.pdf file2.pdf file3.pdf
- Convert PDFs to PDF/A-2 format:
gs_batch --pdfa=2 file1.pdf file2.pdf
- Compress and Convert PDFs to PDF/A-2 format all pdfs in a folder:
gs_batch --compress --pdfa=2 *.pdf
- Apply custom Ghostscript options:
gs_batch --options="-dPDFSETTINGS=/screen -dColorImageResolution=72" file.pdf
- Add prefix^[you can also specify new folder] and suffix to output files:
gs_batch --prefix="./compressed/" --suffix="_v1" --compress=/screen file*.pdf
Output
After processing, gs_batch will display a summary table showing the original size, new size, compression ratio, and which file was kept for each processed PDF. The tool will also attempt to open the output folder in your default file manager.
Requirements
- Python 3.12+
- Ghostscript
- click
- tqdm
- showinfm
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License.
Acknowledgements
gs_batch uses Ghostscript for PDF processing. Ghostscript is released under the GNU Affero General Public License (AGPL).
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
Built Distribution
File details
Details for the file gs_batch_pdf-0.1.1b0.tar.gz
.
File metadata
- Download URL: gs_batch_pdf-0.1.1b0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3a8065db127a0655aabdeaf1b8680f6637d7f0790c085f3ede50f823dd749b7 |
|
MD5 | 286fe8ef13826283bacb5ccf361f6d9c |
|
BLAKE2b-256 | 0f36ec35929c57e8d74af27ab4c853a2d3f59d0a396046fcd9dd8ade8ae02bd8 |
File details
Details for the file gs_batch_pdf-0.1.1b0-py3-none-any.whl
.
File metadata
- Download URL: gs_batch_pdf-0.1.1b0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5fc06d301a48c52063efcdd7d8b668e858ca152e8140afc3f1323a74da12aa7 |
|
MD5 | 80575a543efaf6eb0b714d07adc06065 |
|
BLAKE2b-256 | 3482cdb2e98feed1c06055958771d01841c1cfbd3bc456f6a0b2eb10f6a41960 |