fix: Reject sub-pixel resizes and wrap vips errors - #145
Merged
Merged
Conversation
Model::Transformations#resize scaled through vector2d's fit and handed the result straight to vips, with nothing equivalent to the guard ImageSizing#fit applies on the render path. A result under a pixel reached thumbnail_image(0, height: 0), so "0x0" raised a raw Vips::Error and "1x1" against a 320x200 image silently produced a 1x1 file after vips clamped the zero height and logged GLib criticals. Both now raise InvalidSizeOptions, the same error the render path raises for the same size. transform_image also wraps Vips::Error in InvalidImage, matching ProcessedImage#normalized, so a vips failure on unreadable stored data surfaces as a DynamicImage error from rotate as well as resize.
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.
Model::Transformations#resizescaled through vector2d'sfitand handed the result straight to vips, with nothing equivalent to the guardImageSizing#fitapplies on the render path — so a result under a pixel reachedthumbnail_image(0, height: 0), where"0x0"raised a rawVips::Errorand"1x1"against a 320x200 image silently produced a 1x1 file after vips clamped the zero height and logged GLib criticals. Both now raiseInvalidSizeOptions, the same error the render path raises for the same size; the"1x1"case is the only behaviour change, and it lines the write path up with whatImageSizing#fithas rejected since #142.transform_imagealso wrapsVips::ErrorinInvalidImage, matchingProcessedImage#normalized, so a vips failure on unreadable stored data surfaces as a DynamicImage error fromrotateas well asresize.