Conversation
Photos were stored and served at full original resolution (up to 5MB avatars, 10MB event photos) with no thumbnail generation, so every consumer — member lists, comment popovers, tiny avatar thumbnails, event cards — downloaded the full-size original and relied on CSS to shrink it. Resize on upload with Pillow: avatars cap at 512px, event photos at 1600px. Unreadable formats (e.g. HEIC without a plugin) fall back to storing the original unchanged rather than failing the upload.
image/heic was accepted as an upload type but Pillow has no built-in HEIC codec, so resize_image() silently passed the original bytes through unresized and unconverted. HEIC also doesn't render in browsers, so stored photos with a .heic extension were unreadable in the app. Adds pillow-heif and registers its opener so Pillow can decode HEIC, and always converts HEIC/HEIF uploads to JPEG on save so the stored file is actually displayable.
…ression bombs - skip resize for animated GIFs (thumbnail+save would flatten to one frame) - apply ImageOps.exif_transpose before resizing so rotated phone photos don't render sideways once orientation metadata is dropped on re-encode - catch Image.DecompressionBombError so a small, high-pixel-count image falls back to the original instead of 500ing the upload - trim resize_image's docstring/comments to satisfy the single-line comment convention
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
resize_image()inconfig/media_proxy.py(Pillow, already a dependency via Django'sImageField) and wired it into both upload endpoints: avatars cap at 512px, event photos at 1600px.Test plan
ruff check/ruff format --checkcleanty checkcleanpytest tests/test_photos.py— 21 passed, including new resize-dimension assertions for both profile and event photo uploadsNote: existing already-uploaded photos in prod/staging remain full-size until re-uploaded; no backfill included in this PR.