DNG/RAW photo support for gallery upload

- Server: accept .dng in OCR endpoint (PIL opens as TIFF)
- Server: bump OCR size limit to 20MB (DNG files can be large)
- Client: gallery upload tries server OCR first (with 6s timeout),
  then falls back to client-side Tesseract.js — matches 📸 capture flow
- DNG photos now work with 'Pick from Gallery'
This commit is contained in:
2026-05-21 14:51:57 -04:00
parent 97699a95ea
commit 0cf5dddf83
2 changed files with 25 additions and 4 deletions
+3 -3
View File
@@ -2629,12 +2629,12 @@ async def ocr_sticker(file: UploadFile = File(...)):
"""
# Validate file extension
ext = file.filename.rsplit(".", 1)[-1].lower() if "." in (file.filename or "") else ""
if ext not in {"png", "jpg", "jpeg", "webp", "bmp"}:
if ext not in {"png", "jpg", "jpeg", "webp", "bmp", "dng"}:
raise HTTPException(status_code=400, detail=f"Unsupported image format: .{ext}")
contents = await file.read()
if len(contents) > 10 * 1024 * 1024: # 10MB max
raise HTTPException(status_code=400, detail="Image too large (max 10MB)")
if len(contents) > 20 * 1024 * 1024: # 20MB max
raise HTTPException(status_code=400, detail="Image too large (max 20MB)")
# Save temp file for OCR
temp_dir = Path(UPLOADS_DIR / "ocr")