JPG utils for smartstacks - #470
Open
timbeccue wants to merge 8 commits into
Open
Conversation
timbeccue
marked this pull request as ready for review
July 21, 2026 18:15
There was a problem hiding this comment.
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_utilswith 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_sizeshould be validated before passing it tothumbnail(). Formax_size <= 0, Pillow behavior is error-prone and the intent is clearer if we raise aValueErrorup 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 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) |
This was referenced Aug 6, 2026
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.
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_thumbnailorsmall_thumbnailbefore the file extension.