Skip to content

JPG utils for smartstacks - #470

Open
timbeccue wants to merge 8 commits into
mainfrom
feature/smartstack-pr2-jpg
Open

JPG utils for smartstacks#470
timbeccue wants to merge 8 commits into
mainfrom
feature/smartstack-pr2-jpg

Conversation

@timbeccue

@timbeccue timbeccue commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

This PR adds two capabilities: generate smartstack jpg filenames, and create stretched jpg files.

Jpg stretching uses auto-stretch (see this repository) and pillow for file creation. Both are new dependencies for the project.

Jpg filenames are created using a simple modification of the smartstack filename, inserting large_thumbnail or small_thumbnail before the file extension.

@timbeccue
timbeccue marked this pull request as ready for review July 21, 2026 18:15
@timbeccue
timbeccue requested a review from cmccully July 21, 2026 18:15
@timbeccue timbeccue changed the title Smartstack filenames and JPEG utilities JPG Utils for Smartstacks Jul 21, 2026
@timbeccue timbeccue changed the title JPG Utils for Smartstacks JPG utils for Smartstacks Jul 21, 2026
@timbeccue timbeccue changed the title JPG utils for Smartstacks JPG utils for smartstacks Jul 21, 2026
@cmccully
cmccully requested a review from Copilot August 4, 2026 20:09

@cmccully cmccully left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks fine.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces JPEG-related utilities to support smartstack workflows: generating deterministic thumbnail JPEG filenames from smartstack FITS names, and producing display-ready stretched grayscale JPEG previews using auto-stretch + Pillow.

Changes:

  • Add banzai.utils.jpg_utils with FITS-to-display stretching and JPEG writing helpers.
  • Add make_jpg_filenames() to derive small/large thumbnail JPEG filenames from smartstack filenames.
  • Add test coverage for the new utilities and introduce new runtime dependencies (auto-stretch, pillow).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
uv.lock Locks new dependencies (auto-stretch, pillow) for reproducible installs.
pyproject.toml Adds auto-stretch and pillow to project dependencies.
banzai/utils/jpg_utils.py Implements stretching/decimation and grayscale JPEG saving helpers.
banzai/utils/file_utils.py Adds smartstack-derived thumbnail JPEG filename generator.
banzai/tests/test_jpg_utils.py Tests stretch behavior (dtype/shape/NaN handling) and JPEG sizing/mode.
banzai/tests/test_file_utils.py Tests filename generation for .fits and .fits.fz inputs.
Suppressed comments (1)

banzai/utils/jpg_utils.py:51

  • max_size should be validated before passing it to thumbnail(). For max_size <= 0, Pillow behavior is error-prone and the intent is clearer if we raise a ValueError up front.
    image = Image.fromarray(np.asarray(display_image, dtype=np.uint8))
    image.thumbnail((max_size, max_size))
    image.save(path, quality=quality)

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

Comment thread banzai/utils/jpg_utils.py
Comment on lines +16 to +18
longest_side = max(data.shape)
stride = max(1, math.ceil(longest_side / max_size))
display_data = np.asarray(data[::stride, ::stride], dtype=np.float64)
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.

3 participants