Ensure pre-commit tests by adding actions #1352
Conversation
|
@henrykironde I have a proposed solution for replacing the Image.MAX_IMAGE_PIXELS = None line with a tiled raster check, based on your feedback here: #1324 (comment) Want me to open a follow-up PR that implements it? That way the |
|
@henrykironde Following up on your tiled raster check suggestion — I've looked deeper into the implementation: The current global import rasterio
import warnings
# PIL default: int(1024 * 1024 * 1024 // 4 // 3) = 89,478,485
PIL_PIXEL_LIMIT = 89_478_485
def _check_large_image(raster_path):
"""Pre-flight check: detect large images and route to optimal strategy."""
try:
with rasterio.open(raster_path) as src:
total_pixels = src.width * src.height
is_tiled = src.profile.get('tiled', False)
if total_pixels > PIL_PIXEL_LIMIT:
if is_tiled:
warnings.warn(
f"Large tiled raster ({total_pixels:,} pixels). "
f"Auto-switching to 'window' strategy."
)
return "window"
else:
raise ValueError(
f"Image ({total_pixels:,} pixels) exceeds PIL limit "
f"and is not tiled. Convert with:\n"
f" gdal_translate -of GTiff -co TILED=YES input.tif output.tif"
)
except rasterio.errors.RasterioIOError:
# Non-raster format (PNG/JPG) - continue with default strategy
pass
return NoneEdge cases I've identified: Non-raster fallback: rasterio.open() fails on PNG/JPG — needs graceful handling (not just crash) I'd like to implement this as a follow-up PR to #1326 with tests. Happy to get started if this direction works! |
* Move Image.MAX_IMAGE_PIXELS assignment to after import statements * Add precommit step to actions fix #1352
|
Thanks @musaqlain and @vickysharma-prog for working on this issue. I’m still reviewing how we should handle large files, and once I finalize the approach I’ll update you on the next steps regarding the PIL pixel limit issue and the overall design. |
Add GitHub Actions to enforce pre-commit tests alongside existing app tests