Expanded functionality of oiiotool --resize #3751
Merged
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.
Currently, --resize takes a single argument giving an "image geometry" (like "640x480") that designates the size of the result image, and the rescaling specifically maps the "full size" (a.k.a. display window) of the input image to the output.
This experimental change extends --resize to accept additional new optional modifiers:
":from=" Overrides the default of the full window of the source.
":to=" Overrides the default of the full window of the destination.
":offset=+x+y" Adds an additional offset transformation to the destination.
":edgeclamp=<0|1>" Turns on and off some special edge sample clamping to try to reduce certain ringing artifacts. (Experimental.)
Unlike the output resolution, which like all image sizes must be an integer resolution, the overrides on the source and destination windows and the offset is allowed to be floating point, that is, allowing for fractional pixel sizes or offsets.
The from and to windows do not restrict the boundaries of pixels computed, but rather, simply define the transformational mapping between the two images: the transformation will be chosen such that the float-valued coordinates of the source image correspond exactly to the float-valued coordintes within the destination image. In both cases, coordinates refer to the true continuous coordinates in the image plane, with (0.0, 0.0) being the "upper left" corner, and pixel centers being at half-unit positions such as (ipixel+0.5, jpixel+0.5).
For example,
creates a 1000x503 pixel image where the full output image is a resized version of the 100x50.3 pixel window starting at coordinates (50,20) in the input image.
This is mostly implemented (when it doesn't end up equivalent to the old style resize) in terms of the existing IBA::warp() function. I needed to add a new variety of warp() to avoid some artifacts, but I do this tentatively and so currently do not expose it as part of the public API. I want to gain some experience with the oiiotool usage by the users who requested this, then will return later to exactly how it should be exposed directly as IBA functions.