Skip to content

feat: add thumbnail generation for shared analysis results#948

Open
Anusmita12 wants to merge 2 commits into
imDarshanGK:mainfrom
Anusmita12:feat/image-thumbnails
Open

feat: add thumbnail generation for shared analysis results#948
Anusmita12 wants to merge 2 commits into
imDarshanGK:mainfrom
Anusmita12:feat/image-thumbnails

Conversation

@Anusmita12

Copy link
Copy Markdown

Implements a thumbnail generation pipeline for shared analyses. When a user shares an analysis result that contains embedded images, a small preview thumbnail is automatically generated and stored alongside the share record. Thumbnails are displayed in the query history list view for quick visual identification.

Shared analyses containing images had no preview, making list views and sharing previews unhelpful. This addresses the issue by adding a server-side image processing pipeline using Pillow to downscale embedded images into lightweight WebP thumbnails.

Changes made:

  • backend/app/services/thumbnail.py — new Pillow-based image downscaler (320×180 WebP)
  • backend/requirements.txt — added Pillow>=10.0.0
  • backend/app/schemas.py — added images field to ShareCreateRequest, thumbnail field to ShareRecord
  • backend/app/models.py — added nullable thumbnail column to SharedSnippet
  • backend/app/routers/share.py — calls generate_thumbnail on share creation, stores and returns result
  • frontend/index.html — collects embedded images on share, saves thumbnail to history, displays thumbnail in history list
  • backend/tests/test_thumbnail.py — basic tests for the thumbnail service

Screenshots
Screenshot 2026-06-08 at 11 58 23 AM

Screenshot 2026-06-08 at 11 58 31 AM Screenshot 2026-06-08 at 11 50 21 AM

@Anusmita12 Anusmita12 requested a review from imDarshanGK as a code owner June 8, 2026 06:34
Copilot AI review requested due to automatic review settings June 8, 2026 06:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds thumbnail preview support for shared analysis results by sending embedded images from the frontend, generating a downscaled thumbnail on the backend, and displaying it in the frontend history list.

Changes:

  • Frontend now includes embedded result images in the share payload and renders returned thumbnails in history items
  • Backend generates and stores a thumbnail from the first provided image
  • Adds Pillow dependency and minimal thumbnail service tests

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
frontend/index.html Sends embedded images with share request; renders thumbnail previews in history UI
backend/app/services/thumbnail.py Introduces thumbnail generation from base64/data URLs via Pillow
backend/app/routers/share.py Generates thumbnail during share creation and returns it in the response
backend/app/schemas.py Extends share request/record schemas with images input and thumbnail output
backend/requirements.txt Adds Pillow dependency for image processing
backend/tests/test_thumbnail.py Adds basic tests for invalid/empty inputs to thumbnail generator
README.md Documents new “Thumbnail Previews” capability

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

THUMB_QUALITY = 72


def _b64_to_pil(data_url: str) -> Optional[Image.Image]:
Comment on lines +7 to +11
try:
from PIL import Image
PIL_AVAILABLE = True
except ImportError:
PIL_AVAILABLE = False
Comment thread backend/app/schemas.py
code: str = Field(..., min_length=1, max_length=settings.max_code_chars)
result: dict[str, Any] | None = Field(default=None)
result_json: str | None = Field(default=None)
images: list[str] = Field(default_factory=list)
Comment thread frontend/index.html
Comment on lines 4028 to +4029
<div class="history-item" onclick="loadEntry('${h.id}')" tabindex="0" role="button" aria-label="${getTranslation('history_entry_label').replace('{lang}', h.lang || '?').replace('{time}', h.ts)}" onkeydown="if(event.key==='Enter'||event.key===' ') { event.preventDefault(); loadEntry('${h.id}'); }">
${h.thumbnail ? `<img src="${h.thumbnail}" alt="preview" style="width:56px;height:32px;object-fit:cover;border-radius:4px;flex-shrink:0;">` : ''}
Comment on lines +1 to +7
from app.services.thumbnail import generate_thumbnail

def test_generate_thumbnail_returns_none_for_invalid_input():
assert generate_thumbnail("not_valid_base64") is None

def test_generate_thumbnail_returns_none_for_empty_string():
assert generate_thumbnail("") is None No newline at end of file
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.

2 participants