Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMF to PNG transformation errors #1

Closed
monsieuremre opened this issue Nov 28, 2023 · 4 comments
Closed

EMF to PNG transformation errors #1

monsieuremre opened this issue Nov 28, 2023 · 4 comments

Comments

@monsieuremre
Copy link

First of all, there is a very small error in the image conversion script.

The loop header for image_name, image_path in images_to_convert needs to be replaced with for image_name, image_path in images_to_convert.items(): else python throws an error. For this I will create a pull, but there is a more important issue with image conversion.

Unlucky for us the word documents include EMF files, which are non-universal and quite a bad choice for documentation purposes. This a proprietary file format from microsoft and is not an image per se, but rather as the name suggests, it is a meta file. It is a set of instructions as to how to construct an image.

We are doing the right thing by converting these into the universal png format. But here, the conversion requires the use of libraries that are to the best of my knowledge limited to windows only. Under other computer operating systems such as Mac OS or GNU/Linux or Chrome OS, opening a EMF file in python will result in the following error:
no decode delegate for this image format `EMF'.

Viewing the images works fine on these OS'es, but working with them is quite the hastle, which includes opening them in python. On these operating systems, there are ways to manually do the conversion from emf to png. There are several third party tools and libraries that work on Mac OS and Linux that I have tested.

I suggest the following changes:

  • Mention these limitations in the readme and provide instructions as to how to address these issues manually when needed.

I am going to create a pull request. If you would like to address this in another way please let me know. Waiting for feedback before creating the pull.

Copy link

🚀 Transformation initiated! Once complete, the bot will comment with a link to the converted files.

@monsieuremre
Copy link
Author

I have done some testing and I can confirm I can 100% reproduce the script conversion behavior by using the commands:
emf2svg-conv --input image.emf --output image.svg and then convert image.svg image.png
using emf2svg and imagemagick.

There are other methods for conversion as well, on both mac os and linux and other unix systems, but these result in slightly different png's regarding density and resolution. The aforemention method results in the very same output as the script, on Linux and Mac OS. Despite my efforts, I could not get the script to work with the same behavior on Mac and Linux systems. So on non-windows, I think manual conversion is the only way.

I am going to create a pull request. If you would like to address this in another way please let me know. Waiting for feedback before creating the pull.

So I stand behind my suggestion still, since I couldn't fix it in the script. Limitations for non-windows operating systems should be mentioned in the readme file and some instructions should be added on how to reproduce the same conversion one to one on other operating systems.

@zrgt
Copy link
Collaborator

zrgt commented Nov 29, 2023

@monsieuremre thanks for the issue report. We can document in readme, that conversion does not work on Linux and Mac OS. It would be enough. We should not put more effort into solving this problem.

@monsieuremre
Copy link
Author

Opened in the wrong repo so closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants