Files
label-extractor/render_eps.py
gkonoplya 6850f3672e Implement CLI commands for batch extraction and PDF generation
- Added command-line interface using Click for `batch_extractor.py` to handle extraction from ZIP and PDF files.
- Enhanced `save_to_excel` function to create parent directories for output files.
- Updated `build_pdf.py` to include a CLI for generating PDF labels from Excel data.
- Improved README.md with detailed usage instructions for the new CLI commands.
- Added `click` to requirements.txt for command-line functionality.
2026-02-21 13:20:08 +03:00

27 lines
1000 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import os
import PIL.EpsImagePlugin
# 1. ПОРТАТИВНОСТЬ: Вычисляем путь относительно этого скрипта
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
gs_path = os.path.join(BASE_DIR, 'Ghostscript', 'bin')
# Добавляем в PATH
os.environ['PATH'] = gs_path + os.pathsep + os.environ.get('PATH', '')
# 2. ХАК: Принудительно заставляем Pillow использовать 32-битную версию
# Мы устанавливаем имя бинарника ДО того, как Pillow начнет его искать
PIL.EpsImagePlugin.gs_binary = "gswin32c"
'''
from PIL import Image
file_path = './data/d46349f7-148a-4301-b6b5-f9a3c70fdf19_04639970975115_2000.eps'
try:
img = Image.open(file_path)
img.load(scale=10)
img.save('./data/output.png', 'PNG')
print("Успех! Файл сохранен в ./data/output.png")
except Exception as e:
print(f"Опять ошибка: {e}")
'''