Repository navigation
image(): align the scaled image, not its box, with keep_aspect_ratio and x="C"/"R"/"L" - #2136
Merged
andersonhc merged 2 commits intoNov 10, 2026
Conversation
Collaborator
|
@allcontributors please add @vladosskins178 for code |
|
I've put up a pull request to add @vladosskins178! 🎉 |
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.
Fixes #2131
When
xis"L","C"or"R"andkeep_aspect_ratio=True,x_by_align()already returns the x of the scaled image._raster_image()and_vector_image()then passed that x toscale_inside_box()with the full box width, which added half of the unused width a second time. Now the x fromx_by_align()is kept and onlyy,wandhcome fromscale_inside_box(). A numericxis unchanged: the image is still centered in the box.With a square image in a 100x50 box on A4 (left / right edge of the image, in mm):
x"L""C""R"An image that fills the box width (e.g. a wide image in the same box) is placed the same as before.
Checklist:
A unit test is covering the code added / modified by this PR:
test_image_fit_in_rect_with_x_align(PNG and SVG, each with L / C / R). It fails on master and passes with the fix.In case of a new feature, docstrings have been added, with also some documentation in the
docs/folder: N/A, bug fixA mention of the change is present in
CHANGELOG.mdThis PR is ready to be merged
Full test suite: 2639 passed, 3 skipped, 4 xfailed (Python 3.12, with qpdf).
black,pylint,mypyclean;pyrightshows only the same 3 missing-module errors as master here (endesive, uharfbuzz not installed).By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.