From 2a734ba5969a0bf4ae78a2bce68022fe2cee769b Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Fri, 17 Apr 2026 23:39:51 +0700 Subject: [PATCH] fix: align image dimensions to FLUX.1 divisible-by-8 requirement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- includes/core/class-image-pipeline.php | 4 +++- includes/providers/class-cloudflare-image-provider.php | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/core/class-image-pipeline.php b/includes/core/class-image-pipeline.php index 02e1348..7dafb7b 100644 --- a/includes/core/class-image-pipeline.php +++ b/includes/core/class-image-pipeline.php @@ -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). diff --git a/includes/providers/class-cloudflare-image-provider.php b/includes/providers/class-cloudflare-image-provider.php index 734dead..9554965 100644 --- a/includes/providers/class-cloudflare-image-provider.php +++ b/includes/providers/class-cloudflare-image-provider.php @@ -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 ) {