Spaces:
Runtime error
Runtime error
Download utils/ghostscript_utils.py from cloudaiRambo/cloudairambo: direct link, hf CLI and curl.
- Browser
- Download file 567 Bytes
-
https://huggingface.co/spaces/cloudaiRambo/cloudairambo/resolve/main/utils/ghostscript_utils.py
- Command line
-
hf download hf://spaces/cloudaiRambo/cloudairambo/utils/ghostscript_utils.py
-
curl -L -o ghostscript_utils.py https://huggingface.co/spaces/cloudaiRambo/cloudairambo/resolve/main/utils/ghostscript_utils.py
567 Bytes
| import subprocess | |
| import os | |
| import uuid | |
| from core.config import settings | |
| def compress_pdf(input_path: str): | |
| output_filename = f"{uuid.uuid4()}.pdf" | |
| output_path = os.path.join(settings.OUTPUT_DIR, output_filename) | |
| cmd = [ | |
| "gs", | |
| "-sDEVICE=pdfwrite", | |
| "-dCompatibilityLevel=1.5", | |
| "-dPDFSETTINGS=/ebook", | |
| "-dNOPAUSE", | |
| "-dQUIET", | |
| "-dBATCH", | |
| f"-sOutputFile={output_path}", | |
| input_path, | |
| ] | |
| subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| return output_path | |