Unify background and interpolation handling for mapim transformations - #216
Merged
kipcole9 merged 1 commit intoJul 24, 2026
Merged
Conversation
Collaborator
|
Wow, such amazing work, thank you very much! I'm travelling at the moment but will review and aim to merge by the end of the weekend. |
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.
mapim-based transformations now handle transparent and semi-transparent backgrounds consistently through shared option validation and conditional alpha premultiplication.ripple: added:backgroundand:interpolateoptionsto_polar_coordinates: added:backgroundand:interpolateoptionsto_rectangular_coordinates: added:interpolateoption, and hard-codedextend: :VIPS_EXTEND_COPY. Boundary samples will now be clamped to source edge color instead of blending towards the zero-filldistort: added:background,:interpolate(default is still:bicubicas before), and:extend_modeoptions (:backgroundand:copyaccepted)warp_perspective: now preserves image alpha and reproduces non-opaque backgrounds correctly, added:interpolateoptionstraighten_perspective: now preserves image alpha and reproduces non-opaque backgrounds correctly, added:interpolateoptionmap: now reproduces non-opaque backgrounds correctly, added:interpolateoptionThe
:interpolateoption defaults to:bilinear, except fordistort, which retains its existing:bicubicdefault.For transformations that accept
:background, the default (when omitted or nil) is libvips' all-zero fill: black for images without alpha, transparent for images with alpha.The existing premultiplication handling was extracted into a shared helper, and all affected operations are now routed through a shared
mapimhelper which applies explicit premultiplication when required.I also removed the following doc note from
to_rectangular_coordinatesbecause the roundtrip resamples the image twice, so some accuracy loss is expected, and forcing:extendto:VIPS_EXTEND_COPYalso removes the background-bleed artifacts.Breaking changes:
warp_perspective,straighten_perspectivenow preserve alpha instead of always flattening, so output band count and pixels may change.mapnow defaults to transparent black (all-zero) for exposed pixels in images with alpha (previously opaque black)to_rectangular_coordinatesnow clamps boundary samples to the source edge (extend: :VIPS_EXTEND_COPY)Image.Options.WarpPerspectivewas removed and replaced byImage.Options.Mapim, so direct references to the old module no longer compile.