python-openxml / python-docx

Create and modify Word documents with Python
MIT License
4.66k stars 1.14k forks source link

picture format: EMF #193

Open gisworksca opened 9 years ago

gisworksca commented 9 years ago

I am looking for a way to insert .emf picture to Word document using Python, and found this module. But it doesn't seem this file type is supported yet? I got error "docx.image.exceptions.UnrecognizedImageError". Would this be some feature that could be added? Is there any other python module that could support this? Thanks!

khanzf commented 7 years ago

I ran into this as well. Certain image formats seem to be failing. The issue lays in this being incomplete: https://github.com/python-openxml/python-docx/blob/master/docx/image/__init__.py#L19

I found an old Google cached page that has several image formats displayed:, which might be useful to add. https://webcache.googleusercontent.com/search?q=cache:me_oCCnCZSwJ:https://www.filesignatures.net/index.php%3Fpage%3Dall%26order%3DSIGNATURE%26sort%3DDESC%26alpha%3D+&cd=1&hl=en&ct=clnk&gl=us

I'm working on a patch, but I am not familiar with images and might not be successful...

khanzf commented 7 years ago

I did a pull request for my custom format here: https://github.com/python-openxml/python-docx/pull/423 If you need me to make a custom addition, please share an example EMF format and I'll go ahead and make that change for you.

akselx commented 6 years ago

@khanzf If you are still up for adding EMF support here's an example EMF file.

malcolmroberts commented 5 years ago

There's PR 196 which seems to solve this issue; any chance that this can be merged?