Skip to content

fix: image dimensions for Altair PNG outputs#9149

Merged
Light2Dark merged 2 commits intomarimo-team:mainfrom
daizutabi:fix-altair-png-width-height-to-int
Apr 13, 2026
Merged

fix: image dimensions for Altair PNG outputs#9149
Light2Dark merged 2 commits intomarimo-team:mainfrom
daizutabi:fix-altair-png-width-height-to-int

Conversation

@daizutabi
Copy link
Copy Markdown
Contributor

📝 Summary

This PR fixes a bug introduced in #9049.

Altair returns width and height metadata as float values for PNG. However, these values are used as the width and height attributes of an <img> element in the frontend. These attributes expect integer values.

Changes

  • Cast width and height to int in the Altair formatter's _format_png_mimebundle function.

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Apr 13, 2026 8:59am

Request Review

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 12, 2026

Bundle Report

Bundle size has no change ✅

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression in the Altair PNG formatter where PNG width/height metadata is emitted as floats, but consumed by the frontend as <img> attributes that require integers.

Changes:

  • Cast Altair PNG metadata width/height to int when constructing the marimo MIME bundle.

Comment thread marimo/_output/formatters/altair_formatters.py Outdated
Copy link
Copy Markdown
Collaborator

@Light2Dark Light2Dark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! thank you

@Light2Dark Light2Dark merged commit 66f782e into marimo-team:main Apr 13, 2026
35 of 40 checks passed
@daizutabi daizutabi deleted the fix-altair-png-width-height-to-int branch April 13, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants