feat: generate 150px thumbnail on upload (spec 001, closes #1)#2
Merged
Conversation
Inserts a thumbnail step in process_one after the existing resize: a fresh Image is opened from the original bytes, Pillow's thumbnail() constrains the longest side to THUMBNAIL_MAX_DIMENSION (150) with aspect ratio preserved, and the result is uploaded to thumbnails/<base_filename> in the same bucket. thumbnail_key is added to the DynamoDB metadata item and the returned dict. Unit tests assert exact thumbnail dimensions (150x113 for a 2000x1500 input), the thumbnail_key in the DynamoDB item, and that existing resized/ behaviour is unchanged. Integration test polls for the thumbnails/ object alongside resized/. Infra: two additive env vars in the Lambda environment block; no new resources. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Title: feat: generate 150px thumbnail on upload (spec 001)
Body:
Summary
Adds a thumbnail generation step to the image-processing pipeline. Every upload to
uploads/now produces a 150px (longest-side) thumbnail underthumbnails/with aspect ratio preserved, and the DynamoDB metadata record gains athumbnail_keyattribute.Linked spec / issue
specs/001-thumbnail/spec.mdAcceptance criteria
uploads/object a corresponding object is created underthumbnails/with the same base filename — satisfied by:test_resize_detect_and_persistassertscall_args_list[1].kwargs["Key"] == "thumbnails/photo.jpg"and the integration test pollshead_objectforthumbnail_keytest_resize_detect_and_persistassertsthumb.size == (150, 113)for a 2000×1500 input; a 150×150 square would fail this assertionthumbnail_keyattribute — satisfied by:test_resize_detect_and_persistandtest_pipeline_survives_missing_rekognitionboth assertitem["thumbnail_key"] == {"S": "thumbnails/photo.jpg"}resized/object and all current metadata fields still produced — satisfied by:call_args_list[0]assertsresized/photo.jpgwith max side ≤ 1024; all pre-existing DynamoDB fields asserted present;test_pipeline_survives_missing_rekognitionstill passes unchangedthumb.size == (150, 113)) andthumbnail_keyDynamoDB assertion intest_resize_detect_and_persistthumbnails/object appears after upload to LocalStack — satisfied by:test_upload_triggers_pipelinepollshead_objectforthumbnail_keyand assertsthumbnail_foundruff check .clean and CI green — satisfied by: ruff passes locally; CI runs unit + integration-localstack jobs on this PRVerification
ruff check .cleanpytest tests/test_handler.pypasses locallyGuardrails
uploads/S3 event filter unchangedhandler.pyremains environment-agnostic