PptxGenJS
PptxGenJS copied to clipboard
image placed in placeholder loses aspect ratio
Hi, I am using pptxgenjs version 3.7.1. I created a slide master with a placeholder of type "pic", with width=height=2. When I insert an image with a different aspect ratio in this placeholder, its aspect ratio is not maintained, regardless of what I provide in the sizing property. I would like my image to be contained in the placeholder, while maintaining its aspect ratio.
with ph : PlaceholderProps sourceW = image.width sourceH = image.height
slide.addImage({data:image.src, x: ph.x, y:ph.y, w: sourceW, h: sourceH, sizing: { type: "contain", w: ph.w as number, h: ph.h as number }});
--> OK
slide.addImage({data:image.src, placeholder: placeholder, w: sourceW, h: sourceH, sizing: { type: "contain", w: ph.w as number, h: ph.h as number }});
--> KO
Is this feature supported in 3.7.1? And if so, what properties should I send to addImage to get the expected result?
Ideally I would like to provide the placeholder name without knowing its size and position, and just provide the sizing type.
slide.addImage({data:image.src, placeholder: placeholder, w: sourceW, h: sourceH, sizing: { type: "contain"});
Thanks Cl.
@ccassan - so when you use the same values for w
and h
in the two examples above, you're saying the image has 2 different aspect ratios once generated?
@gitbrent , yes, the only difference in the two calls is the placeholder.
It works now in 3.12.0, the ratio is maintained
slide.addImage({ data:image.src, placeholder: placeholder, w: sourceW, h: sourceH, sizing: { type: "contain", w: ph.w as number, h: ph.h as number } });