kling-o1-pro and kling-o1-std silently fail when aspect_ratio is included
in the payload — they derive it from the input image. Added
VIDEO_ASPECT_RATIO_MODELS whitelist so only kling-elements and minimax-hailuo
receive the parameter.
Also switched image_to_base64 to use Pillow for format detection instead of
trusting the file extension, which correctly handles files saved with the
wrong extension.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Models like mystic, flux-pro-1.1, and seedream-v4/v4-5 require named
aspect ratio slugs (e.g. "square_1_1", "widescreen_16_9") while other
models accept the "W:H" format directly.
- Add normalize_aspect_ratio() mapping W:H strings to slugs for affected models
- Apply normalization in generate-image before building the request payload
- Improve FreepikAPIError to surface invalid_params field details from the API
response, so "Validation error" now also shows which field failed and why
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>