- Created .gitignore to exclude unnecessary files and directories. - Implemented build_pdf.py for generating PDF labels from Excel data, including barcode rendering. - Added read_image.py for extracting DataMatrix codes from images using zxing-cpp. - Introduced render_eps.py for converting EPS images to PNG format with Ghostscript. - Updated README.md with project overview, features, installation instructions, and usage guidelines. - Included requirements.txt for dependency management. - Added resources for logos and sample Excel template. - Compressed Ghostscript binaries into Ghostscript.zip for easy integration.
25 lines
992 B
Python
25 lines
992 B
Python
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}") |