Skip to content

fix: Render extreme aspect ratios instead of raising - #150

Merged
elektronaut merged 1 commit into
mainfrom
rescue-subpixel-invalid-size-options
Sep 20, 2026
Merged

elektronaut merged 1 commit into
mainfrom
rescue-subpixel-invalid-size-options

Conversation

@elektronaut

Copy link
Copy Markdown
Owner

ImageSizing#fit has raised InvalidSizeOptions since #142 when a fitted size lands under a pixel, which the view helpers reach for an image far enough from square. dynamic_picture_tag goes sub-pixel at its smallest breakpoints past roughly 350:1, and dynamic_image_tag raises past the width it is asked for — size: "1200x" past 1200:1, a 50 pixel thumbnail past 50:1. Neither image rendered before #142 either, but the failure moved from one broken img to a raise in the view, so a single uploaded image takes down every page that renders it.

ImageSizing#fit_renderable returns the smallest size the image can be rendered at, the whole frame scaled until its short side is one pixel, rather than raising. dynamic_image_tag and dynamic_image_url render at that size, and the tag lays the image out at the size that was asked for, so a 2000x1 image asked for "1200x" renders 2000x1 and reports a width of 1200 and a height of 1. Growing the size keeps the image's own aspect, so the frame is never cropped, and the file is never larger than the stored image: 352 bytes for a 1000x2 WebP.

Picture drops the candidate widths it can't render instead, since a srcset descriptor has to match the width of the file behind it. An image too extreme for any breakpoint gets a single candidate at its own width.

Requesting a size with crop: true still raises when the crop leaves less than a pixel, as does Model::Transformations#resize.

ImageSizing#fit has raised InvalidSizeOptions since #142 when a fitted
size lands under a pixel, which the view helpers reach for an image far
enough from square. dynamic_picture_tag goes sub-pixel at its smallest
breakpoints past roughly 350:1, and dynamic_image_tag raises past the
width it is asked for: size: "1200x" past 1200:1, a 50 pixel thumbnail
past 50:1. Neither image rendered before #142 either, but the failure
moved from one broken img to a raise in the view, so a single uploaded
image takes down every page that renders it.

ImageSizing#fit_renderable returns the smallest size the image can be
rendered at, the whole frame scaled until its short side is one pixel,
rather than raising. dynamic_image_tag and dynamic_image_url render at
that size, and the tag lays the image out at the size that was asked
for, so a 2000x1 image asked for "1200x" renders 2000x1 and reports a
width of 1200 and a height of 1. Growing the size keeps the image's own
aspect, so the frame is never cropped, and the file is never larger than
the stored image: 352 bytes for a 1000x2 WebP.

Picture drops the candidate widths it can't render instead, since a
srcset descriptor has to match the width of the file behind it. An image
too extreme for any breakpoint gets a single candidate at its own width.

Requesting a size with crop: true still raises when the crop leaves less
than a pixel, as does Model::Transformations#resize.
@elektronaut
elektronaut merged commit 6ed8514 into main Sep 20, 2026
6 checks passed
@elektronaut
elektronaut deleted the rescue-subpixel-invalid-size-options branch September 20, 2026 18:27
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.

1 participant