fix: use glob matching for Gemini image MIME types#12511
Merged
comfyanonymous merged 1 commit intoComfy-Org:masterfrom Feb 18, 2026
Merged
fix: use glob matching for Gemini image MIME types#12511comfyanonymous merged 1 commit intoComfy-Org:masterfrom
comfyanonymous merged 1 commit intoComfy-Org:masterfrom
Conversation
gemini-3-pro-image-preview nondeterministically returns image/jpeg instead of image/png. get_image_from_response() hardcoded get_parts_by_type(response, "image/png"), silently dropping JPEG responses and falling back to torch.zeros (all-black output). Add _mime_matches() helper using fnmatch for glob-style MIME matching. Change get_image_from_response() to request "image/*" so any image format returned by the API is correctly captured.
guill
approved these changes
Feb 18, 2026
a11171c to
370810c
Compare
comfyanonymous
pushed a commit
that referenced
this pull request
Feb 18, 2026
gemini-3-pro-image-preview nondeterministically returns image/jpeg instead of image/png. get_image_from_response() hardcoded get_parts_by_type(response, "image/png"), silently dropping JPEG responses and falling back to torch.zeros (all-black output). Add _mime_matches() helper using fnmatch for glob-style MIME matching. Change get_image_from_response() to request "image/*" so any image format returned by the API is correctly captured.
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
gemini-3-pro-image-previewnondeterministically returnsimage/jpeginstead ofimage/pngin responseinlineData.get_image_from_response()hardcodesget_parts_by_type(response, "image/png"), which silently drops JPEG responses and falls back totorch.zeros((1, 1024, 1024, 4))— producing all-black (0,0,0,0 RGBA) output images.Confirmed via API response logs: successful runs had
mimeType: "image/png", failed (black) runs hadmimeType: "image/jpeg". 100% correlation.Fix
_mime_matches()helper usingfnmatchfor glob-style MIME matching (e.g."image/*"matches"image/png","image/jpeg","image/webp")get_parts_by_type()to use_mime_matches()instead of==for MIME comparisonget_image_from_response()to request"image/*"instead of"image/png"Uses
mime.value(notstr(mime)) to ensure correct behavior on Python 3.10 wherestr()on astrEnum returns"ClassName.member"instead of the value.API Node PR Checklist
Scope
Pricing & Billing
If Need pricing update:
QA
Comms