feat: ensure image output format matches file extension
- Add hokusai/image.py with Pillow-based format detection and conversion - Pass output_format to OpenAI gpt-image models and BFL API - Convert mismatched images after provider writes (fallback for all providers) - Handle RGBA-to-RGB flattening for JPEG targets - Add Pillow dependency
This commit is contained in:
parent
d8e0ed561d
commit
770f408dad
7 changed files with 348 additions and 92 deletions
|
|
@ -19,6 +19,7 @@ from hokusai.config import (
|
|||
ProjectConfig,
|
||||
)
|
||||
from hokusai.graph import build_graph, get_build_order, get_subgraph_for_target
|
||||
from hokusai.image import ensure_image_format
|
||||
from hokusai.prompt import extract_placeholder_files, resolve_prompt
|
||||
from hokusai.providers import Provider
|
||||
from hokusai.providers.blackforest import BlackForestProvider
|
||||
|
|
@ -170,6 +171,7 @@ async def _build_single_target(
|
|||
|
||||
if isinstance(target_cfg, DownloadTargetConfig):
|
||||
await _download_target(target_name, target_cfg, project_dir)
|
||||
ensure_image_format(output_path)
|
||||
return
|
||||
|
||||
model_info = resolve_model(target_name, target_cfg, config.defaults)
|
||||
|
|
@ -184,6 +186,9 @@ async def _build_single_target(
|
|||
project_dir=project_dir,
|
||||
)
|
||||
|
||||
# Ensure the output image format matches the file extension.
|
||||
ensure_image_format(output_path)
|
||||
|
||||
|
||||
def _cleanup_stale_targets(
|
||||
config: ProjectConfig,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue