A collection of Python utilities and scripts for study and productivity tasks.
A PDF compression tool that uses Ghostscript to reduce PDF file sizes while maintaining acceptable quality. Perfect for compressing large PDFs to meet upload size limits.
Features:
- Multiple compression quality levels (screen, ebook, printer, prepress)
- Automatic compression strategy selection to meet target file size
- Batch processing support for multiple PDFs
- Progress tracking and detailed statistics
- Preserves PDF quality while reducing file size
Scripts:
pdf_reducer.py- Single PDF compression with customizable quality settingsbatch-reduce.py- Batch process multiple PDFs in a directory
This project requires Python 3.6+ and Ghostscript.
Install Ghostscript:
macOS:
brew install ghostscriptLinux (Ubuntu/Debian):
sudo apt-get install ghostscriptLinux (Fedora/RHEL):
sudo dnf install ghostscriptWindows:
- Download the Windows installer from Ghostscript official website
- Run the installer and follow the installation wizard
- Make sure to check "Add to PATH" during installation
- Verify installation by opening Command Prompt and running:
or
gswin64c -version
gswin32c -version
Note for Windows users: If Ghostscript is not in your PATH, you may need to add it manually:
- Default installation path:
C:\Program Files\gs\gs[version]\bin - Add this path to your System Environment Variables
git clone https://github.com/Yen-Coder/Study-Tools
cd Study-ToolsSingle PDF Compression:
cd pdf-size-reducer
python3 pdf_reducer.py input.pdf output.pdf --target 30Options:
--target: Target file size in MB (default: 30)--quality: Initial quality level (screen/ebook/printer/prepress)
Batch PDF Compression:
cd pdf-size-reducer
python3 batch-reduce.py /path/to/pdf/folder --target 30Options:
--output: Output directory for compressed PDFs (default: input_dir/compressed)--target: Target file size in MB (default: 30)
Examples:
Compress a single PDF to under 30 MB:
Linux/macOS:
python3 pdf_reducer.py large_document.pdf compressed_document.pdfWindows (Command Prompt):
python pdf_reducer.py large_document.pdf compressed_document.pdfWindows (PowerShell):
python pdf_reducer.py large_document.pdf compressed_document.pdfCompress all PDFs in a directory:
Linux/macOS:
python3 batch-reduce.py ~/Documents/PDFs --output ~/Documents/Compressed_PDFs --target 25Windows (Command Prompt):
python batch-reduce.py C:\Users\YourName\Documents\PDFs --output C:\Users\YourName\Documents\Compressed_PDFs --target 25Windows (PowerShell):
python batch-reduce.py C:\Users\$env:USERNAME\Documents\PDFs --output C:\Users\$env:USERNAME\Documents\Compressed_PDFs --target 25Study-Tools/
├── pdf-size-reducer/
│ ├── pdf_reducer.py # Single PDF compression script
│ └── batch-reduce.py # Batch PDF compression script
├── .gitignore
├── .gitattributes
└── README.md
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
This repository is designed to grow with additional study and productivity tools. Stay tuned for more utilities!