Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

images in tutorials are rendered too large if not constrained by page width #192

Closed
grst opened this issue May 24, 2023 · 3 comments · Fixed by #285
Closed

images in tutorials are rendered too large if not constrained by page width #192

grst opened this issue May 24, 2023 · 3 comments · Fixed by #285

Comments

@grst
Copy link
Collaborator

grst commented May 24, 2023

image

@grst grst changed the title images in documentation are rendered too large if not constrained by page width images in tutorials are rendered too large if not constrained by page width May 24, 2023
@flying-sheep
Copy link
Member

flying-sheep commented Jun 6, 2023

Matplotlib is configured to use a high DPI, and communicates the metadata about “CSS pixels” via Jupyter cell metadata.

{
  "data": {
    "image/png": "",
    "text/plain": ["<Figure size 480x480 with 1 Axes>"]
  },
  "metadata": {
    "image/png": {
      "height": 398,
      "width": 390
    }
  },
  "output_type": "display_data"
}

It looks like myst-nb adds that metadata to the docutils image node, but somehow it doesn’t end up in the <img> tag.

Possible causes might be

  1. that myst-nb has its own cell.metadata.myst metadata key and might read that one only, not the plain cell.metadata.width/height keys.
  2. that the metadata is unitless and is probably read from the notebook as an int.

Maybe myst-nb adding px to unitless width or height would work? docutils says it wants a “length” or “percentage”, which maybe has to be a string with “px” or “%” at the end

@flying-sheep
Copy link
Member

@grst could you file an issue for myst-nb? https://github.com/executablebooks/MyST-NB/issues/new?assignees=&labels=bug&projects=&template=bug_report.yml

@grst
Copy link
Collaborator Author

grst commented May 18, 2024

This has been fixed. TODO: require myst-nb>=v1.1.0 in the template.

grst added a commit that referenced this issue May 21, 2024
Fixes issue with images rendering too large in tutorials. 
Close #192
@grst grst closed this as completed in #285 May 21, 2024
grst added a commit that referenced this issue May 21, 2024
Fixes issue with images rendering too large in tutorials. 
Close #192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants