Honor blipFill <a:stretch><a:fillRect> cover crop on PPTX import#297
Conversation
|
Warning Review limit reached
Your plan includes 1 review of capacity. Refill in 49 minutes and 35 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR adds support for PPTX image cover-crop via ChangesPPTX blipFill fillRect Crop Support
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
bf91949 to
3709cbd
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/tasks/active/20260525-pptx-blipfill-fillrect-crop-todo.md`:
- Around line 33-37: The fenced code block containing "l,t,r,b = insets /
100000" etc. is missing a language tag and triggers markdownlint MD040; update
the opening fence from ``` to include a language token (e.g., ```text or
```python) so the block is fenced with a language, keeping the block content
unchanged and ensuring markdownlint passes.
- Around line 51-52: Update the checklist entry that currently references
`test/import/pptx/image.test.ts` to use the repository-relative path
`packages/slides/test/import/pptx/image.test.ts` so the checklist accurately
points to the test file included in this PR; edit the checkbox line in the
markdown to replace the old path with the new one.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ab1fa4de-3809-44a2-a584-6272c1effd7d
📒 Files selected for processing (5)
docs/design/slides/slides-themes-layouts-import.mddocs/tasks/README.mddocs/tasks/active/20260525-pptx-blipfill-fillrect-crop-todo.mdpackages/slides/src/import/pptx/image.tspackages/slides/test/import/pptx/image.test.ts
Verification: verify:selfResult: ✅ PASS in 216.8s
Verification: verify:integrationResult: ✅ PASS |
PowerPoint places photos as <p:sp> freeform shapes filled with <a:blipFill>. When the shape's frame aspect ratio differs from the photo's, PowerPoint reconciles them with a negative <a:stretch> <a:fillRect> (Fill/cover crop): it scales the image past the shape bounds and the shape clips it. The importer's parseBlipFill read only <a:srcRect> and ignored <a:stretch><a:fillRect>, so with no crop the renderer stretched the whole image into the frame, squishing it (e.g. a 2:3 portrait into a square shape on slide 3 of the daycare deck). Derive the equivalent source Crop from the negative fillRect (cover case only — within [0,1]); the default all-zero fillRect is a no-op and positive-inset/letterbox fillRects fall back to a full stretch. Reuses the existing Crop pipeline, so no model or renderer change. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
3709cbd to
a24bdf2
Compare
These tasks landed on main per recent commit log: docker-publish-arm64 (#296), import-progress-toast (#299), pptx-blipfill-fillrect-crop (#297), release-v0.4.2 (#295), slides-textbox-autogrow (cf83a49), and slides-textbox-edit-theme-color (#300). Move their docs to archive/2026/05 and regenerate the task indexes. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
These tasks landed on main per recent commit log: docker-publish-arm64 (#296), import-progress-toast (#299), pptx-blipfill-fillrect-crop (#297), release-v0.4.2 (#295), slides-textbox-autogrow (cf83a49), and slides-textbox-edit-theme-color (#300). Move their docs to archive/2026/05 and regenerate the task indexes. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Importing a
.pptxwhere a photo is placed as a<p:sp>freeform shape with<a:blipFill>distorted the image when the shape's frame aspect ratio differed from the photo's. PowerPoint reconciles the mismatch with a negative<a:stretch><a:fillRect>(its "Fill" / cover crop): it scales the image past the shape bounds and the shape clips it. Our importer read only<a:srcRect>(source crop) and ignored<a:stretch><a:fillRect>, so with no crop the renderer stretched the whole image into the frame — squishing it.Repro: "Blue Green Colorful Daycare Center Presentation.pptx", slide 3 — a 1200×1800 (2:3 portrait) photo placed in a square frame via
fillRect l="-31963" t="-36905" r="-9496" b="-75284". The fill-region AR works out to exactly the photo's native 2:3, so PowerPoint shows it undistorted; we squished it. Slide 8 has 3 more.Fix
A negative/zero
fillRect(cover case) is mathematically the dual of a source crop, which the model and renderer already support.parseStretchFillRect()inimage.tsderives the equivalent sourceCropwhen<a:srcRect>yields none:Applied only when the result stays within
[0,1](cover). Default all-zerofillRect→ no-op; positive-inset/letterboxfillRect→ falls back to full stretch. No model or renderer change — reuses the existingCroppipeline (so backgrounds via<p:bgPr>benefit too).Limitations (accepted for v1)
srcRecttakes precedence;srcRect+fillRectare not composed.<a:tile>fills unchanged; non-rect freeform clip paths still not honored (pre-existing).Note
Only affects new imports — an already-imported document must be re-imported to pick up the corrected crop.
Test plan
pnpm --filter @wafflebase/slides test— 1301 pass, incl. 5 newimage.test.tscases (cover crop with real slide-3 values, all-zero no-op, positive-inset skip, degeneratefw<=0skip, srcRect precedence).pnpm verify:fast— green.<p:grpSp>) withcrop = {x:0.226, y:0.174, w:0.707, h:0.471}; cropped-source pixel AR ≈ 1.0 = the square frame ⇒ no distortion.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation
Tests