fix(recipe): fall back to original image for metadata extraction when optimized lacks embedded data (#968)

When CivitAI API returns meta=null and the optimized CDN image has no
embedded generation parameters (e.g. PNG tEXt chunks stripped by
Cloudflare Images), download the original image as fallback to recover
full recipe metadata (prompt, seed, LoRAs, etc.).

Also fixes Chrome password manager popping up on recipe save by adding
autocomplete="new-password" to the settings API key and proxy password
fields.
This commit is contained in:
Will Miao
2026-06-10 15:06:56 +08:00
parent cb8c699224
commit 7cbddd9cf7
3 changed files with 75 additions and 2 deletions

View File

@@ -176,6 +176,24 @@ class RecipeAnalysisService:
self._exif_utils.extract_image_metadata, temp_path
)
if not metadata and civitai_image_id and image_info:
original_url = image_info.get("url")
if original_url:
self._logger.debug(
"Optimized image lacks embedded metadata, "
"falling back to original image: %s",
original_url,
)
orig_temp_path = self._create_temp_path(suffix=".png")
try:
await self._download_image(original_url, orig_temp_path)
metadata = await asyncio.to_thread(
self._exif_utils.extract_image_metadata,
orig_temp_path,
)
finally:
self._safe_cleanup(orig_temp_path)
result = await self._parse_metadata(
metadata or {},
recipe_scanner=recipe_scanner,