fix: align image dimensions to FLUX.1 divisible-by-8 requirement

FLUX.1 schnell requires width and height to be divisible by 8.
The default OG image size 1200×630 has 630 % 8 = 6 remainder,
causing HTTP 400 on every image generation call.

Changes:
- Pipeline default height 630 → 632 (nearest 8-aligned value)
- Provider now rounds any dimension to nearest multiple of 8 as
  a defensive guard before sending to the API

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
peptiderepo
2026-04-17 23:39:51 +07:00
parent 6cf8ff62fc
commit 2a734ba596
2 changed files with 7 additions and 1 deletions

View File

@@ -27,8 +27,10 @@ class PRAutoBlogger_Image_Pipeline {
/**
* Default image dimensions (landscape).
*/
// FLUX.1 requires both dimensions to be divisible by 8.
// 1200×632 is the closest 8-aligned pair to the standard OG image size (1200×630).
private const DEFAULT_WIDTH = 1200;
private const DEFAULT_HEIGHT = 630;
private const DEFAULT_HEIGHT = 632;
/**
* The image provider (FLUX.1 via Cloudflare or another).

View File

@@ -69,6 +69,10 @@ class PRAutoBlogger_Cloudflare_Image_Provider implements PRAutoBlogger_Image_Pro
* @throws \RuntimeException On auth failure, bad response shape, or retry exhaustion.
*/
public function generate_image( string $prompt, int $width, int $height, array $options = [] ): array {
// FLUX.1 requires dimensions divisible by 8; round to nearest valid value.
$width = (int) ( round( $width / 8 ) * 8 );
$height = (int) ( round( $height / 8 ) * 8 );
$this->assert_valid_dimensions( $width, $height );
$prompt = trim( $prompt );
if ( '' === $prompt ) {