From af8b84931184473602940dddc14b9895763a28d2 Mon Sep 17 00:00:00 2001 From: "Dhanji R. Prasanna" Date: Thu, 22 Jan 2026 07:58:05 +0530 Subject: [PATCH] fix(read_image): use correct media type when resize fails to reduce size When resize_image_to_dimensions() returns a larger file than the original, we fall back to using the original bytes. Previously, was_resized was set to true if the original dimensions exceeded MAX_IMAGE_DIMENSION, which caused final_media_type to be set to 'image/jpeg' even though we were using the original PNG bytes. This caused Anthropic API errors like: 'Image does not match the provided media type image/jpeg' Fix: Set was_resized=false when falling back to original bytes, so the original media type (detected from magic bytes) is preserved. --- crates/g3-core/src/tools/file_ops.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/g3-core/src/tools/file_ops.rs b/crates/g3-core/src/tools/file_ops.rs index 5eecb85..e1dc6de 100644 --- a/crates/g3-core/src/tools/file_ops.rs +++ b/crates/g3-core/src/tools/file_ops.rs @@ -355,9 +355,9 @@ pub async fn execute_read_image( if resized_size < original_size { (resized, true) } else { - // Resize didn't help, use original but warn if it's huge + // Resize didn't help, use original bytes with original media type debug!("Resize didn't reduce size, using original"); - (bytes, original_dimensions.map(|(w, h)| w > MAX_IMAGE_DIMENSION || h > MAX_IMAGE_DIMENSION).unwrap_or(false)) + (bytes, false) } } Err(e) => {