Skip to content

Resize QTI images at publish to their authored size - #6219

Draft
rtibblesbot wants to merge 2 commits into
learningequality:unstablefrom
rtibblesbot:issue-6189-ddc7c9
Draft

rtibblesbot wants to merge 2 commits into
learningequality:unstablefrom
rtibblesbot:issue-6189-ddc7c9

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Images resized in the QTI editor published at full size: the QTI package shipped the original file, and the derived Perseus archive dropped the size entirely. Each sized <img> now ships a resized copy per size in both archives, with width/height kept in the QTI XML and =WxH plus a filled images map in the Perseus markdown. The shared resize path also now keeps GIF animation, EXIF orientation and JPEG colour profiles, and ships the original when a resize fails.

References

Refs #6189. Refs #6213. Refs #6215 (overlaps #6216). Kolibri display: learningequality/kolibri#15383.

Reviewer guidance

Python tests pass on CI.

Legacy publish output changes:

  • Sized SVGs ship a copy per size with root width/height (and a viewBox when missing).
  • Animated images at natural size or over MAX_ANIMATED_IMAGE_PIXELS ship the original.
  • Same-size re-encodes ship only when smaller than the original.
  • Legacy <img> in the QTI package now carries width/height.

Open risk:

  • Only unprefixed <img> tags are rewritten; a foreign package using a namespace prefix ships full-size files.
Unmet criterion Reason
Resized image shows at its authored size in Kolibri's QTI viewer Package contents tested; display in Kolibri not checked end to end.
Derived Perseus archive shows at that size in older Kolibri Archive contents tested; display in older Kolibri not checked.
Same image at two sizes shows at each size in both formats Both archives tested; display in Kolibri not checked.
Sized images keep aspect ratio on narrow screens Kolibri-side rendering; not checked in Kolibri.

AI usage

Used Claude Code to plan and implement the publish-time resize and its tests. Verified with the tests/utils/ suite and pre-commit.

🤖 Generated with Claude Code

Closes #6189


@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Ran pre-flight CI checks (lint, format, tests) and verified all pass
  • Rebased onto the target branch and resolved any conflicts
  • Reorganized commit history into clean, logical commits
  • Audited the diff to ensure only issue-relevant files are changed
  • Built PR body from the repository's PR template with evidence blocks
@rtibblesbot

🟢 Reviewing PR

Last updated: 2026-09-30 18:38 UTC

rtibblesbot and others added 2 commits September 30, 2026 09:06
- Animated GIFs resize every frame, keeping timing and loop; originals ship at natural size or over MAX_ANIMATED_IMAGE_PIXELS.
- EXIF-rotated photos come out upright; JPEGs keep their ICC profile.
- Same-size re-encodes ship only when smaller than the original.
- Sized SVGs get root width/height (and a viewBox when missing).
- A failed resize ships the original instead of a dangling reference.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Sized <img> (integer width and height) ship a resized copy per size in the QTI package; width/height stay in the XML.
- Rewrites go per element, so one image at two sizes ships two files.
- Derived Perseus markdown carries ` =WxH`, so publish resizes and fills the images map.
- Legacy items keep the size on their QTI <img>.

Refs learningequality#6189

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@rtibblesbot

Copy link
Copy Markdown
Contributor Author

Outside this PR's scope — tracked under #5998:


@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Ran pre-flight CI checks (lint, format, tests) and verified all pass
  • Rebased onto the target branch and resolved any conflicts
  • Reorganized commit history into clean, logical commits
  • Audited the diff to ensure only issue-relevant files are changed
  • Built PR body from the repository's PR template with evidence blocks

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 this pull request may close these issues.

[QTI] Image sizes set in the editor are lost when exercises are rendered in Kolibri

1 participant