Add initial project structure and core functionality for label extraction and PDF generation

- 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.
This commit is contained in:
2026-02-21 11:46:24 +03:00
commit 93b28b1ea2
10 changed files with 707 additions and 0 deletions

25
render_eps.py Normal file
View File

@@ -0,0 +1,25 @@
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}")