Skip to content

Spike: Crop image to a rounded rectangle#1433

Draft
niranjan-uma-shankar wants to merge 3 commits into
gitbrent:masterfrom
niranjan-uma-shankar:feature/html-to-pptx
Draft

Spike: Crop image to a rounded rectangle#1433
niranjan-uma-shankar wants to merge 3 commits into
gitbrent:masterfrom
niranjan-uma-shankar:feature/html-to-pptx

Conversation

@niranjan-uma-shankar

@niranjan-uma-shankar niranjan-uma-shankar commented Dec 23, 2025

Copy link
Copy Markdown

This extends the PPTXGenJS library to support rounded rectangle cropping of an image. This is used to crop a Chronicle card's background image to the same dimensions of a Chronicle card widget.

PPTXGenJS doesn't provide a straightforward way to overlay a background image on a rounded rectangle (a rect with all edges having a border radius). So, this approach directly crops the background image to have rounded corners.

Steps

  1. Checkout branch
  2. npm install
  3. To compile the library source changes, run:
npm run build && cp src/bld/pptxgen.cjs.js dist/pptxgen.cjs.js && cp src/bld/pptxgen.es.js dist/pptxgen.es.js
  1. Run node add_image_with_rounding.js . You should now see a new Image_With_Rounding.pptx in the project folder.

shbernal added a commit to shbernal/PptxGenJS that referenced this pull request Jun 8, 2026
addImage() now accepts `shape` (any preset geometry name, e.g. roundRect,
hexagon, ellipse) and `rectRadius`. `rounding: true` stays as shorthand for
`shape: 'ellipse'`; `shape` takes precedence when both are set.

Previously the picture geometry was a hardcoded `rounding ? 'ellipse' : 'rect'`.
Shape and image paths now share a `genXmlPresetGeom` helper so preset emission
and adjust-value handling (rectRadius/angleRange/arcThicknessRatio) live in one
place. Combine with `sizing: { type: 'cover' }` for aspect-correct fills.

Adds test/regression/image-shape.test.js. Marks upstream signals PR gitbrent#1433 and
issue gitbrent#850 as implemented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant