You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR modifies how percent regions larger than 100%, request an image from cantaloupe at the upper bound of the image, rather than larger so that instead of receiving an error from cantaloupe for requesting an image larger than the size, the image will be returned
When a request's {region} extends beyond the image's dimensions (e.g. pct:0,0,101,101, or 3471,5079,512,512 on a 3771x5279 image) the IIIF spec says the service should crop at the image's edge:
If the request specifies a region which extends beyond the dimensions of the full image as reported in the image information document, then the service SHOULD return an image cropped at the image’s edge, rather than adding empty space.
iiif-net's RegionParameter.GetExtractedRegionSize() already does this cropping when calculating the extracted region size, so Orchestrator's size/maxWidth calculations were correct. However the original region was still proxied to the image server unaltered, which Cantaloupe rejects (e.g. pct: > 100 results in a 500 Width must be <= 1).
How this fixes it
Orchestrator now rewrites the region before proxying, the same way it already rewrites the size parameter:
IIIFX.ConfineToImageBounds(RegionParameter, Size) - returns a copy of the region with w/h reduced so that x + w and y + h don't exceed the image bounds. The bound is 100 for pct: regions and the image's width/height for pixel regions. full and square are returned unaltered.
pct:0,0,101,101 ➡️ pct:0,0,100,100
pct:50,50,60,60 ➡️ pct:50,50,50,50
6632,3682,512,512 on a 6932x3982 image ➡️ 6632,3682,300,300
ImageProxyPathHandler - calls ConfineToImageBounds after GetExtractedRegionSize (so requests where x/y are outside the image still fail validation first) and returns the result on the new ProxyImageRequest.ProxyRegionParameter property.
ImageRequestHandler - sets IIIFImageRequest.Region from ProxyRegionParameter alongside the existing Size rewrite, so the image server only ever receives an in-bounds region.
IsFullOrEquivalent is now evaluated against the confined region, so a region like pct:0,0,101,101 or 0,0,7000,4000 (on a 6932x3982 image) is treated as a full-region request and is a candidate for being served by thumbs / special-server, same as full or pct:0,0,100,100.
Unchanged behaviour
Regions where x or y are outside the image (e.g. pct:101,0,10,10) still return 400 Region is outside image bounds, and zero width/height regions still return 400.
Tests
Unit tests for ConfineToImageBounds covering pixel and percent regions, full and square.
ImageProxyPathHandlerTests - V2 and V3 (strict + lax) tests asserting the confined region + resulting size, and additional "represents full region" cases for oversized regions.
ImageHandlingTests integration tests asserting the region in the URI proxied to the image server is cropped for both pixel and pct: regions.
JackLewis-digirati
changed the title
Mae percent requests that exceed 100% bound to 100%
Make percent requests that exceed 100% bound to 100%
Sep 28, 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
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.
What does this change?
Resolves #1117
This PR modifies how percent regions larger than 100%, request an image from cantaloupe at the upper bound of the image, rather than larger so that instead of receiving an error from cantaloupe for requesting an image larger than the size, the image will be returned