Bug Report
Library version
docx 9.6.1
Problem
ImageRun with transformation: { width, height } produces wildly incorrect EMU dimensions when large pixel values are used.
The transformation property expects pixel values and multiplies by 9525 to convert to EMU. However, if you accidentally pass an EMU-sized number as pixels (e.g. width: 5029200 intending 5.5 inches), the value gets multiplied again to cx="47903130000" — equivalent to ~52,000 inches.
Symptoms
-[Word for Mac 16.107] refuses to open the .docx file entirely
- Google Docs opens the file but shows a black square instead of the image
- The Claude.ai preview pane shows no image
Root cause
The XML produced contains:
<wp:extent cx="47903130000" cy="26945510625"/>
Which is ~52,000 inches wide. The correct value for a 5.5" image is:
<wp:extent cx="5029200" cy="2828925"/>
Workaround
Use small pixel values (e.g. width: 528, height: 297 for a 5.5" image at 96 DPI), or patch the EMU values directly in the XML after document generation.
Suggested fix
Add validation or documentation warning when transformation values exceed a reasonable pixel range (e.g. > 10000 pixels should trigger a warning).
Discovered while building a document with three embedded JPEG images using Claude AI and docx 9.6.1.
Bug Report
Library version
docx 9.6.1
Problem
ImageRunwithtransformation: { width, height }produces wildly incorrect EMU dimensions when large pixel values are used.The
transformationproperty expects pixel values and multiplies by 9525 to convert to EMU. However, if you accidentally pass an EMU-sized number as pixels (e.g.width: 5029200intending 5.5 inches), the value gets multiplied again tocx="47903130000"— equivalent to ~52,000 inches.Symptoms
-[Word for Mac 16.107] refuses to open the .docx file entirely
Root cause
The XML produced contains:
Which is ~52,000 inches wide. The correct value for a 5.5" image is:
Workaround
Use small pixel values (e.g.
width: 528, height: 297for a 5.5" image at 96 DPI), or patch the EMU values directly in the XML after document generation.Suggested fix
Add validation or documentation warning when
transformationvalues exceed a reasonable pixel range (e.g. > 10000 pixels should trigger a warning).Discovered while building a document with three embedded JPEG images using Claude AI and docx 9.6.1.