excel2pic/tests/test_high_dpi.py

32 lines
899 B
Python

import pytest
import io
import os
from core.renderer import ExcelRenderer
from PIL import Image
TEST_FILE_PATH = "tests/kshj_gt1767081783800.xlsx"
@pytest.mark.skipif(not os.path.exists(TEST_FILE_PATH), reason="Test file not found")
def test_high_dpi_rendering():
"""
Test rendering with higher scale factor.
"""
with open(TEST_FILE_PATH, "rb") as f:
content = f.read()
renderer = ExcelRenderer(content)
# Render with scale=3 (High Quality)
img_bytes = renderer.render_to_bytes(scale=3, dpi=300)
assert isinstance(img_bytes, bytes)
assert len(img_bytes) > 0
img = Image.open(io.BytesIO(img_bytes))
# Save for visual inspection
output_path = "tests/test_output_high_dpi.png"
img.save(output_path)
print(f"Generated high DPI test image at: {os.path.abspath(output_path)}")
print(f"Image Size: {img.size}")