| |
|
|
| from PIL import Image |
| from .logging_config import logger |
|
|
| def assess_image_quality(img): |
| try: |
| if img is None: |
| logger.error("No image provided to assess_image_quality.") |
| return { |
| 'resolution': 'unknown', |
| 'quality_score': 0, |
| 'error': 'No image provided' |
| } |
| width, height = img.size |
| resolution = width * height |
| quality_score = min(100, resolution // 20000) |
| return { |
| 'resolution': f"{width}x{height}", |
| 'quality_score': quality_score |
| } |
| except Exception as e: |
| logger.error(f"Error assessing image quality: {str(e)}") |
| return { |
| 'resolution': 'unknown', |
| 'quality_score': 0, |
| 'error': str(e) |
| } |
|
|