Repository navigation
Conversation
… isn't distorted `images replace` kept the old <wp:extent>, stretching the new picture into the old picture's box. It now keeps the displayed width, recomputes the height from the new image's aspect ratio, and scales down (aspect kept) to fit the text area. --width/--height size it like `images add`; --keep-size keeps the old box. Both extents (wp:extent + a:xfrm/a:ext) are updated, an a:srcRect crop is dropped, a tight/through wrap polygon is reset, and every drawing sharing the picture is refitted. A format with no parsed pixel size keeps the box and the ack says so. The ack names the new size. Fixes #46 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LkctEPC6PsxKcGTNCZPmN4 Triage-Routine: true
Owner
Author
|
🤖 docx-cli triage This PR is ready for review and fixes #46. Action needed: approve/merge — review PR #54 and answer the Decisions checklist (whether this matches Word's Change Picture, the height clamp, the invoice scenario asset). Generated by Claude Code |
This branch has not been deployed
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.
🤖 docx-cli triage
What was wrong
images replaceswapped the bytes but kept the old<wp:extent>. A differently-shaped picture got stretched into the old box, and the command still exited 0. With a 400×100 image at 4in replaced by a 100×400 one,readstill saidsize="4x1in", so a 1:4 picture was drawn 4:1.What changed
--width/--heightuse the same length grammar and math asimages add. One flag keeps the aspect ratio; both are honored as given.--keep-sizekeeps the old box and is rejected when combined with--width/--height.<wp:extent>andpic:spPr/a:xfrm/a:extare both updated. An<a:srcRect>crop is dropped. A tight/through<wp:wrapPolygon>is reset to the full frame.↳ kept 2x1.33in: size unknown for .emf — …). A single--width/--heighton such a file is a usage error that writes nothing.images.replace img0 (2x6in).--dry-runreports the size too.src/core/image/refit.tsgetPageContentHeightEmuincore/sections.tsxparseImageSizeshared withimages addformatImageSizeshared with thedocx:imageread hintsrc/core/image/CLAUDE.md, the invoicecriteria.md("logo not distorted")images.tsnow replaces a wide PNG with a new 1:3tests/fixtures/assets/tall.png.Verification
images replace a.docx --at img0 --with tall.pngprintedimages.replace img0andreadstill showedsize="4x1in".images.replace img0 (2.25x9in). At 4in wide the new height would be 16in, so it's scaled down to fit the 9in text height;readshows the same size. With a 2in-wide original:(2x6in).wrapThrough+ polygon): the replace refits it, the polygon is reset, anddocx validatepasses.--width/--height/ both,--keep-sizeand its conflict error, emf (box kept with a note, one-axis refused), a cropped floating image fromlarge-mixed.docx, a shared rId refitted per drawing, and core tests for both extents, the crop, and the wrap polygon.bun run check✅bun run test:unit✅ (2134 tests, run by the pre-push hook)formatImageSizeand reusedcomputeExtentEmufor the native-size fallback. /code-review xhigh: the forked run reviewed the wrong checkout, not this branch, so its results don't apply here. I re-read this diff by hand instead.Decisions for you
scripts/word-redlines.shwithout Word. The default here keeps the width and never distorts.assets/logo.svgis square, like the original logo, so the scenario doesn't exercise a shape change yet. I added a criteria check but left the asset alone. Swap in a non-square logo?--width/--heightonreplaceoverlap feat(images): images set — resize, wrap/float, alt text and captions on an existing image #47's plannedimages setresizing (both touchrespond.tsand the image docs).Fixes #46
Generated by Claude Code