fix(skill): save true PNG output (v3.0.1) - #5
Merged
Conversation
Testing the pipeline end-to-end surfaced a real bug: gemini-3.1-flash-lite-image returns JPEG on the Gemini Developer API, and output_mime_type cannot force PNG there. The CLI was writing those JPEG bytes to a .png file — degrading text quality and misnaming the file — and the refine loop hardcoded image/png when re-sending the image. Fixes: - Transcode the model's output to lossless PNG via Pillow (crisp text, matching the skill's "text accuracy first" promise). - Thread the real mime type from the response through generation, refinement, and saving; write the extension that matches the actual bytes. - Degrade gracefully if Pillow is absent (save native format + warn) so google-genai stays the only hard dependency. - Add pillow to requirements.txt and `--install`; bump skill to 3.0.1 and update README, SKILL.md, and CHANGELOG. Verified end-to-end with a live key: research + image render now produces a 768x1376 PNG, and a refinement round-trips and re-saves as PNG. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA5q9TqsQjnmj6myJeB1g
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.
Pull Request
Summary
Fixes a real bug found by running the skill pipeline end-to-end with a live Gemini key: the CLI was saving JPEG bytes under a
.pngfilename, degrading text (the one thing an infographic must get right).gemini-3.1-flash-lite-imagereturns JPEG on the Gemini Developer API, andoutput_mime_typecan't force PNG there:So the skill now transcodes the model output to lossless PNG. Bumps the skill to 3.0.1, which — with the publish workflow now on
main— auto-publishes a fresh npm version on merge.Changes
save_imagereplaces a mismatched/absent image extension).refine_imagenow re-sends the current image with its true mime type instead of a hardcodedimage/png.google-genairemains the only hard dependency.pillowtorequirements.txtand--install; update README, SKILL.md, CHANGELOG; bumppackage.jsonto 3.0.1.How Tested
npm run lint) — n/a: Python skill + docs only.npm test) — n/a: no app source touched.npm run build) — n/a: no app source touched.py_compile+node --checkpass;npm pack --dry-runclean (5 files, v3.0.1).gemini-3.5-flash) + image (gemini-3.1-flash-lite-image) →filereportsPNG image data, 768 x 1376(previously JPEG).--outputwith no extension correctly yields.png.output_mime_typeon the Developer tier (hence the transcode approach).Screenshots
Example output from this exact pipeline (
"The rise of AI coding agents in 2026…", data-story, 9:16) — note the crisp, accurate text:Image attached in the PR thread / shared separately.
🤖 Generated with Claude Code
Generated by Claude Code