feat: consolidate env config and add deployment files
- Add debug_font_path, demo_docs_dir, e2e_api_base_url to config.py - Fix hardcoded paths in pp_structure_debug.py, create_demo_images.py - Fix hardcoded paths in test files - Update .env.example with new configuration options - Update .gitignore to exclude AI development files (.claude/, openspec/, AGENTS.md, CLAUDE.md) - Add production startup script (start-prod.sh) - Add README.md with project documentation - Add 1panel Docker deployment files (docker-compose.yml, Dockerfiles, nginx.conf) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,11 +3,17 @@
|
||||
Create demo images for testing Tool_OCR
|
||||
"""
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Demo docs directory
|
||||
DEMO_DIR = Path("/Users/egg/Projects/Tool_OCR/demo_docs")
|
||||
# Add backend to path for imports
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from app.core.config import settings
|
||||
|
||||
# Demo docs directory from settings
|
||||
DEMO_DIR = Path(settings.demo_docs_dir)
|
||||
|
||||
def create_text_image(text, filename, size=(800, 600), font_size=40):
|
||||
"""Create an image with text"""
|
||||
@@ -15,15 +21,11 @@ def create_text_image(text, filename, size=(800, 600), font_size=40):
|
||||
img = Image.new('RGB', size, color='white')
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
# Try to use a font, fallback to default
|
||||
# Try to use a font from settings, fallback to default
|
||||
try:
|
||||
# Try system fonts
|
||||
font = ImageFont.truetype("/System/Library/Fonts/STHeiti Light.ttc", font_size)
|
||||
except:
|
||||
try:
|
||||
font = ImageFont.truetype("/System/Library/Fonts/Helvetica.ttc", font_size)
|
||||
except:
|
||||
font = ImageFont.load_default()
|
||||
font = ImageFont.truetype(settings.debug_font_path, font_size)
|
||||
except Exception:
|
||||
font = ImageFont.load_default()
|
||||
|
||||
# Calculate text position (centered)
|
||||
bbox = draw.textbbox((0, 0), text, font=font)
|
||||
@@ -44,12 +46,9 @@ def create_multiline_text_image(lines, filename, size=(800, 1000), font_size=30)
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
try:
|
||||
font = ImageFont.truetype("/System/Library/Fonts/STHeiti Light.ttc", font_size)
|
||||
except:
|
||||
try:
|
||||
font = ImageFont.truetype("/System/Library/Fonts/Helvetica.ttc", font_size)
|
||||
except:
|
||||
font = ImageFont.load_default()
|
||||
font = ImageFont.truetype(settings.debug_font_path, font_size)
|
||||
except Exception:
|
||||
font = ImageFont.load_default()
|
||||
|
||||
# Draw each line
|
||||
y = 50
|
||||
@@ -66,12 +65,9 @@ def create_table_image(filename, size=(800, 600)):
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
try:
|
||||
font = ImageFont.truetype("/System/Library/Fonts/STHeiti Light.ttc", 24)
|
||||
except:
|
||||
try:
|
||||
font = ImageFont.truetype("/System/Library/Fonts/Helvetica.ttc", 24)
|
||||
except:
|
||||
font = ImageFont.load_default()
|
||||
font = ImageFont.truetype(settings.debug_font_path, 24)
|
||||
except Exception:
|
||||
font = ImageFont.load_default()
|
||||
|
||||
# Draw table borders
|
||||
# Header row
|
||||
@@ -115,6 +111,7 @@ def create_table_image(filename, size=(800, 600)):
|
||||
def main():
|
||||
# Create basic text images
|
||||
basic_dir = DEMO_DIR / "basic"
|
||||
basic_dir.mkdir(parents=True, exist_ok=True)
|
||||
create_text_image(
|
||||
"這是中文繁體測試文檔\nTool_OCR 系統測試",
|
||||
basic_dir / "chinese_traditional.png"
|
||||
@@ -146,10 +143,12 @@ def main():
|
||||
"5. 多種格式導出(TXT, JSON, Excel, MD, PDF)",
|
||||
]
|
||||
layout_dir = DEMO_DIR / "layout"
|
||||
layout_dir.mkdir(parents=True, exist_ok=True)
|
||||
create_multiline_text_image(layout_lines, layout_dir / "document.png")
|
||||
|
||||
# Create table image
|
||||
tables_dir = DEMO_DIR / "tables"
|
||||
tables_dir.mkdir(parents=True, exist_ok=True)
|
||||
create_table_image(tables_dir / "simple_table.png")
|
||||
|
||||
print("\n✅ Demo images created successfully!")
|
||||
|
||||
Reference in New Issue
Block a user