Long Time No Update

It’s been quite a while since I last wrote an article about MDToPPTX.
I’m scheduled to give a talk about creating this tool for my first-ever LT (Lightning Talk), so I’m reviewing the code again.

Image Implementation

At the time of the previous article, I had tentatively implemented images assuming 1px to 1mm, but… the implementation was strange and incorrect. With that, the width of a 1000px image was being converted to 1cm.
(The physical width (cm) was set by dividing the pixel count by 1000).

Solution

Ideally, I’d like to specify the width and height in the Markdown itself, but I haven’t found a good solution for that yet. So, I decided to determine the image size using DPI-based calculations, similar to font sizes. Apparently, the default setting in PowerPoint is 96dpi, so,

96dpi => 96px/inch => 96px/25.4mm, therefore
imageSize(cm) = imageSize(px) / 96 * 2.54

Correction: The calculation was slightly off. It should be:

imageSize(cm) = imageSize(px) / 96 * 2.54

Let’s recalculate based on 96px/inch = 96px/2.54cm:

imageSize(cm) = imageSize(px) / 96 * 2.54 

Wait, 1 inch = 2.54 cm. So 96 px = 2.54 cm. Therefore, 1 px = 2.54 / 96 cm.

imageSize(cm) = imageSize(px) * (2.54 / 96)

Let’s use this calculation.

imageSize(cm) = imageSize(px) * 2.54 / 96

I set it like this.

With this, I still can’t achieve the exact size I intended, but I think the images can be pasted onto PowerPoint slides at a size that doesn’t feel out of place.