Capture Object.width/height for GIF uploads (#690 phase 1)#947
Open
vjpixel wants to merge 1 commit into
Open
Conversation
Adds nullable PositiveIntegerField width/height on Object, populated on upload for GIF files via Pillow (already in deps). Sets up the infrastructure for templates and AR/MR rendering to use real dimensions instead of hardcoded 50×50 thumbnails (#473, #319). Phase 2/3 (mp4/webm via ffprobe and glb via pygltflib/trimesh) are deferred — see the comment thread on the issue for the breakdown. Includes: - core.0028 migration adding the fields (objectevent gets the same fields automatically via pghistory). - UploadObjectForm.save now populates width/height when extension is gif. Other extensions leave the fields null until phase 2/3. - New management command `backfill_object_dimensions` for legacy rows: probes GIFs, supports --dry-run, logs failures and skips unreadable files. Verified locally: uploading a 320x240 GIF saves the row with width=320, height=240. Refs #690 https://claude.ai/code/session_01XC1THLWgnGXGf5wgRhdyvB
pablodiegoss
requested changes
May 12, 2026
Member
There was a problem hiding this comment.
We don't have access to run management commands on our servers. This should be implemented as a migration with python operations to populate the missing fields for older records, we have a few examples of this.
This ensures that after the new migrations run, fields are created, older records have the new fields populated and the new code should ensure that new records always populate the field through tests
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.
Summary
Phase 1 of #690 — capture native pixel dimensions for raster uploads on
Object. Lays the groundwork for thumbnails and AR/MR rendering to use real dimensions (refs #473, #319) instead of the hardcoded 50×50 inObject.as_html_thumbnail.Scope is intentionally minimal: only GIF, only via Pillow (already in deps). MP4/WebM (ffprobe) and GLB (pygltflib/trimesh) are deferred — see my comment on the issue for the phased breakdown.
Changes
Object.widthandObject.height(PositiveIntegerField(null=True, blank=True)).core.0028adds the fields.objectevent(pghistory tracking model) gets the same fields automatically.UploadObjectForm.save()populateswidth/heightwhenfile_extension == "gif". Other extensions leave the fields null until phase 2/3.backfill_object_dimensionsfor legacy rows. Iterates GIF rows wherewidth__isnull=True, probes via Pillow, supports--dry-run, logs failures and skips unreadable files.Verified locally
Risk
nulluntil backfill runs.width/heightyet. The follow-up to use these in the AR/MR rendering will arrive once the data is actually populated.Test plan
make testpassesmake migrateapplies cleanlywidth/heightsetwidth/heightnull (expected, phase 2)python src/manage.py backfill_object_dimensions --dry-runreports counts without savingpython src/manage.py backfill_object_dimensionspopulates dimensions for existing GIFsRefs #690 (phase 1)
https://claude.ai/code/session_01XC1THLWgnGXGf5wgRhdyvB
Generated by Claude Code