Page 1 of 2
EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-13T09:00:46-07:00
by chri
Hi,
I try to convert EMF to JPG format. The vector graphics in the EMF files are rather big so I downsize the files using the command
convert -geometry "3307x2244" -units PixelsPerInch -compress "JPEG" %1 -density 300 %1.jpg
Output:
convert.exe: UnableToReadImageData `00010003_1247.emf' @ error/emf.c/ReadEMFImage/753.
convert.exe: no images defined `00010003_1247.emf.jpg' @ error/convert.c/ConvertImageCommand/3230.
For most files it does work. For some it does not and I cannot tell why.
They do open e.g. in Inkscape without any problem.
I get these files from a CAD tool which cannot export any other format. Also the resolution cannot be changed. Thats why I'm looking for a solution to convert these exports in background. If anyone knows a performace tweek I'd be more than happy.
I put the file on google drive
https://drive.google.com/file/d/0B8__Pj ... sp=sharing
Here the version info of the imagemagick I use on my W7x64 System:
Version: ImageMagick 6.9.1-10 Q8 x64 2015-07-25
http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License:
http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
Thanks!!!
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-13T09:54:42-07:00
by fmw42
Put the -density before reading the image and get rid of -geometry and use -resize in stead, but after reading the input image.
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-13T11:28:01-07:00
by chri
Actually it does not matter what parameter I use. Also in a very Basic Syntax "convert <emf> <jpg>" I do get this error.
It must bei relativ to the files somehow. Its not the geometry size as files containing the same geometry plus additional geometris work.
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-13T13:10:33-07:00
by fmw42
-geometry should not be used for resizing.
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-13T13:16:00-07:00
by chri
I appreciate your comments but they do not provide anything pointing to an solution.
Did you download the sample and verify your recommendations work on your system?
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-13T14:07:46-07:00
by fmw42
Unfortunately, my system is not set up to handle EMF files right now, otherwise, I would test it. I was just pointing out one issue with using -geometry. If i get a chance later, I will try to install EMF, if I can find the proper delegate library.
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-14T05:56:48-07:00
by chri
Thanks I changed my script and also updated to the latest version
Version: ImageMagick 6.9.3-0 Q8 x64 2016-01-02
http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License:
http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
I also tried the Q16 and 32bit Versions, still the problem remains
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-14T07:43:57-07:00
by chri
I usually don't work with linux so just for testing I downloaded a Ubuntu virtualbox image and installed ImageMagick.
Unfortunately I couldn't find a delegate library for EMF. Is there actually one for Linux?
I was able to create a pdf from the emf using unoconv though - still not what I want / need
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-14T10:26:06-07:00
by fmw42
My guess is that you need to compile IM adding --with wmf in the ./configure file. But I am not an expert on that.
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-14T16:01:30-07:00
by dlemstra
The problem with this image is that we are probably hitting a memory limit. Your image is 46358x12716 and when we call 'LockBits' this fails. When you lower the density you can get an output image:
Code: Select all
convert -density 10 00010003_1247.emf 00010003_1247.png
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-15T00:31:01-07:00
by chri
Thanks! That does work.
The output in the end should always be 3307x* with 300 dpi for optimal printing. The input files do not always have the same size. Now if I hardcode "-density 10" I might reduce the image size to much and would then upscale the image. Which will not return good results.
Is there an easy way to achieve this?
What is confusing is, that if I open the emf in InkScape and save it without any changes I get an emf file that does actually work without lowering the resolution first
https://drive.google.com/file/d/0B8__Pj ... sp=sharing
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-15T00:34:47-07:00
by fmw42
set a reasonable density for reading the PDF and then set an appropriate density before the output for printing the jpg, perhaps something like
Code: Select all
convert -density 72 00010003_1247.emf -resize 3307x -density 300x300 00010003_1247.png
Use -density 72 or whatever value that will generate an image that is larger than 3307x but small enough that you do not run out of memory or tmp space
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-15T00:45:21-07:00
by chri
For me the two emf seem to have the same content (drawing wise) - same size (lenght x width), different file size (the bigger one works).
The question is how should I know that is an appropriate density for each file. The conversion should be fully automated in background before uploading the files to an ECM system.
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-15T10:33:46-07:00
by fmw42
I know little about EMF files. But take out the first -density and just use
Code: Select all
convert 00010003_1247.emf -resize 3307x -density 300x300 00010003_1247.png
Re: EMF conversion error error/emf.c/ReadEMFImage/753
Posted: 2016-01-15T14:01:32-07:00
by dlemstra
That won't work Fred. The issue is that the @chri needs to know the density that can be used to create a 3307x image. The big image can only be read if a 'low enough' density is specified. The issue is that @chri wants to figure out the best density.