13

Is there any command line tool available to convert emf to png images?

I tried the convert utility from ImageMagick, but it says

decoder for emf not found

5 Answers 5

15

(Found in https://stackoverflow.com/a/28749719)

Use LibreOffice:

libreoffice --headless --convert-to png image.emf
2
  • --convert-to pdf is also allowed! May 5, 2020 at 13:48
  • 1
    may require cropping after the conversion, though May 5, 2020 at 13:49
9

The other answers here did not work for me, but one I found on stakoverflow did

Another way is to use inkscape:

inkscape -e file.png source.emf

See inkscape --help for more export options (area to export, dpi, image resolution, background color etc).

1
  • works fine under Bionic with inkscape v0.92.3
    – bcag2
    Feb 1, 2021 at 16:02
3

According to this page: http://www.imagemagick.org/script/formats.php

EMF R Microsoft Enhanced Metafile (32-bit) Only available under Microsoft Windows.

Source

2
  • Care to explain the downvotes?
    – Jan
    Aug 18, 2018 at 15:39
  • 2
    I did not downvote but it's annoying to have an accepted answer with information that do not help to solve the problem and only partially answer the question when there is two answers that do below. Feb 10, 2020 at 15:18
0

inkscape is a great idea, but unfortunately it does not do a perfect job, for ex. with label positions getting messed in certain cases, as described here: https://gitlab.com/inkscape/inbox/-/issues/2847

So far the only accurate conversion outside of Windows that I've seen is with OpenOffice (headless) or using the unoconv Python script which calls OpenOffice/LibreOffice to do the work. Maybe there's some way to hack together ImageMagick and Mono (libgdi) under Linux but haven't found anything that's done that yet.

0

You can use the good library libemf2svg and after imagick

Install library libemf2svg, example for debian or ubuntu:

git clone [email protected]:kakwa/libemf2svg.git
cd libemf2svg/
sudo apt-get install gcc g++ cmake libpng-dev libfreetype-dev libfontconfig1-dev -y
cmake . -DCMAKE_INSTALL_PREFIX=/usr/
make
sudo make install

Use the lib by ./emf2svg-conv -i test.emf -o test.svg Now you have a svg file. Finally, finish the convert by convert test.svg test.png

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .