Reputation: 196
What is unit of the number we get from prs.slides[4].shapes[3].width, where prs is presentation object in python-pptx? In help, it says English Metric Units, but numbers i am getting do not match that.
Upvotes: 1
Views: 782
Reputation: 28963
An English Metric Unit (EMU) is 1/914400th of an inch, chosen (or perhaps invented) by Microsoft because it allows the position and size of a graphical object (shape) to be specified as an integer (and hence avoid floating-point calculations, performance-related probably mostly) while still allowing both inch (English) and meter (Metric) distances to be expressed as exact integers.
The factors of 914400 are many, but definitely include 25.4 (mm in an inch), 72 (points in an inch); all of 2, 4, 8, 16, and 32 (all the common fractional inches), and 100 (so decimal inches to the .01" resolution commonly available in the US English PowerPoint UI.
Generally, the object returned by a shape distance property (left, top, width, height) is a subclass of an Emu
object which has the properties .inches
, .pts
, .cm
and .mm
which will do the conversion for you into float
common measurement units. So something like:
>>> shape.width.cm
2.54
>>> shape.width.inches
1.0
>>> shape.width.pts
72.0
Upvotes: 2