Crash when opening WMF file

Bug #1434721 reported by su_v
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Confirmed
Medium
Unassigned

Bug Description

On 2015-03-20 14:16 (+0100), John Portnov asked this question:
https://answers.launchpad.net/inkscape/+question/263913

Original question:
==================
I need to load my WMF File into InkScape so that I can work with it and save it as svg file eventually.

Based on what I read, InkScape allows you to open wmf files. When I place WMF file in InkScape it closes and/or crashes.

I have done open, import, and dragged WMF file into InkScape. The result is that InkScape closes without warning.

Version info:
=============
I got InkScape (0.91 version) yesterday and believe that I have the latest version of it.

Test case:
==========
https://www.dropbox.com/s/22kxob0phnn73te/test12.wmf?dl=0

Tags: importing wmf
Revision history for this message
su_v (suv-lp) wrote :
Revision history for this message
su_v (suv-lp) wrote :

Crash confirmed with Inkscape 0.91 r13725 and 0.91+devel r14020 on OS X 10.7.5. UniConverter 1.1.5 also fails to open the file.

The file format by the way is not WMF as suggested, it seems to be an EMF file:

$ file test12.wmf
test12.wmf: Windows Enhanced Metafile (EMF) image data version 0x10000

Renaming the file to test12.emf and attempting to open it in Inkscape doesn't result in a crash, but fails to load with a different error (Inkscape itself does not crash):

Entity: line 591669: parser error : internal error: Huge input lookup
 L 91242.202,-101183.14
        ^
Entity: line 591669: parser error : internal error: Huge input lookup
 L 91242.202,-101183.14
        ^
Entity: line 591669: parser error : Extra content at the end of the document
 L 91242.202,-101183.14
        ^

Even if the file turns out to be damaged (or otherwise unsupported by Inkscape), the application should not crash (instead, it should notify the user that it fails to open the file).

tags: added: importing wmf
Changed in inkscape:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
David Mathog (mathog) wrote :

Does the OP have a way in the generating program to edit this file down to a smaller sample? For instance, select half the drawing and delete it. Save to SVG. Import in Inkscape. If it crashes delete another half. If it doesn't crash delete the other half instead. Rinse and repeat until the drawing is whittled down to the smallest possible sample that crashes.

The example posted has 602398 records in it, and it doesn't go wrong, I think in the SVG parser operating on the SVG made by the EMF conversion routine, until over half a million lines have been processed.

libUEMF's reademf got all the way through it without crashing. However, that output is so huge there is no way I can just eyeball it to see what the problem is.

Revision history for this message
John Portnov (rocketscientist008) wrote : Re: [Bug 1434721] Re: Crash when opening WMF file

No. This is the file I have to work with.

On Fri, Mar 20, 2015 at 7:44 PM, David Mathog <email address hidden>
wrote:

> Does the OP have a way in the generating program to edit this file down
> to a smaller sample? For instance, select half the drawing and delete
> it. Save to SVG. Import in Inkscape. If it crashes delete another
> half. If it doesn't crash delete the other half instead. Rinse and
> repeat until the drawing is whittled down to the smallest possible
> sample that crashes.
>
> The example posted has 602398 records in it, and it doesn't go wrong, I
> think in the SVG parser operating on the SVG made by the EMF conversion
> routine, until over half a million lines have been processed.
>
> libUEMF's reademf got all the way through it without crashing. However,
> that output is so huge there is no way I can just eyeball it to see what
> the problem is.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1434721
>
> Title:
> Crash when opening WMF file
>
> Status in Inkscape: A Vector Drawing Tool:
> Confirmed
>
> Bug description:
> On 2015-03-20 14:16 (+0100), John Portnov asked this question:
> https://answers.launchpad.net/inkscape/+question/263913
>
> Original question:
> ==================
> I need to load my WMF File into InkScape so that I can work with it and
> save it as svg file eventually.
>
> Based on what I read, InkScape allows you to open wmf files. When I
> place WMF file in InkScape it closes and/or crashes.
>
> I have done open, import, and dragged WMF file into InkScape. The
> result is that InkScape closes without warning.
>
> Version info:
> =============
> I got InkScape (0.91 version) yesterday and believe that I have the
> latest version of it.
>
> Test case:
> ==========
> https://www.dropbox.com/s/22kxob0phnn73te/test12.wmf?dl=0
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/inkscape/+bug/1434721/+subscriptions
>

Revision history for this message
David Mathog (mathog) wrote :

On my test machine, Ubuntu 12.04.04LTS 32 bit, I was able to open that file and there were no errors like the ones cited above. This is trunk revision 13947.

However, the resulting SVG was so enormous that the program for all intents and purposes was completely unusable.

The test file was converted to test12_emf.txt using reademf from libUEMF, and to test12.svg using a hacked version of inkscape that diverts the SVG produced on EMF input straight to a file. These are attached in a zip file, because they are huge. The zip is still 7M, but the two other files uncompressed come out to 90M.

Somebody please try loading the SVG version of this test file. If a test system failed with the original EMF it should have the same problem with this. Maybe you can edit it down to a smaller test case.

The EMF is so huge that it is hard to make sense of it, but one thing it seems to be doing is filling spaces by drawing fat lines. The composition of the file is 1 rectangle, 5 Polygons, the usual sorts of header and ending records and these (type, counts):

SETTEXTCOLOR 74991
LINETO 149805
SELECTOBJECT 150013
DELETEOBJECT 76548
MOVETOEX 74461
CREATEPEN 74992
CREATEBRUSHINDIRECT 1556

Mostly what it does is loop on this (and variations thereof):

move to point (x,y).
draw a diagonal line to (x-L,y-L)
draw a horizontal line from there to (x-L+1,y-L)
y=y+6

Even though it sets the text color a lot it does not actually have any text records. Near as I can tell it was probably made by some really low level, really dumb conversion of an old fashioned plotter's input, maybe HPGL? When it does open in inkscape it looks like a drawing with macroscopic objects. It isn't. It's more like a bitmap composed of W x H pixels, where each pixel is itself a separate image.

Revision history for this message
Alvin Penner (apenner) wrote :

I was able to open the file on Windows 7, 32 bit, Inkscape 0.91 r13725 (Jan 30 2015)
- however the svg file size is 26 Mb and I was not able to view the file, it is too large. The dimensions are given by:

   width="1746.26mm"
   height="1349.39mm"

There appears to be a scaling problem in the file. There are literally hundreds of entries of the type given below. The value of 101996 for x is somewhat worrisome, too large compared to page size.

  <path
     style="fill:none;stroke:#9c4a09;stroke-width:156.28575134px;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
     clip-path="url(#clipEmfPath3)"
     d="m 101996,-62416.8 -1300,-1300.3 1,0"
     id="path4540"
     inkscape:connector-curvature="0"
     transform="scale(0.28222222,0.28222222)" />

It appears that this file was probably produced by a program called "Any DWG to Image Converter". If this file was originally an AutoCAD file of type DWG, then you might wish to try saving it as DXF and try loading that into Inkscape, or attach it here.

Revision history for this message
John Portnov (rocketscientist008) wrote :

Thanks for all your efforts. So if I save the DWG file as DXF (instead of
using a conversion tool to make WMF to preserve the format quality),
InkScape will be able to open it?

On Fri, Mar 27, 2015 at 8:31 AM, Alvin Penner <email address hidden> wrote:

> I was able to open the file on Windows 7, 32 bit, Inkscape 0.91 r13725
> (Jan 30 2015)
> - however the svg file size is 26 Mb and I was not able to view the file,
> it is too large. The dimensions are given by:
>
> width="1746.26mm"
> height="1349.39mm"
>
> There appears to be a scaling problem in the file. There are literally
> hundreds of entries of the type given below. The value of 101996 for x
> is somewhat worrisome, too large compared to page size.
>
> <path
>
> style="fill:none;stroke:#9c4a09;stroke-width:156.28575134px;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
> clip-path="url(#clipEmfPath3)"
> d="m 101996,-62416.8 -1300,-1300.3 1,0"
> id="path4540"
> inkscape:connector-curvature="0"
> transform="scale(0.28222222,0.28222222)" />
>
> It appears that this file was probably produced by a program called "Any
> DWG to Image Converter". If this file was originally an AutoCAD file of
> type DWG, then you might wish to try saving it as DXF and try loading
> that into Inkscape, or attach it here.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1434721
>
> Title:
> Crash when opening WMF file
>
> Status in Inkscape: A Vector Drawing Tool:
> Confirmed
>
> Bug description:
> On 2015-03-20 14:16 (+0100), John Portnov asked this question:
> https://answers.launchpad.net/inkscape/+question/263913
>
> Original question:
> ==================
> I need to load my WMF File into InkScape so that I can work with it and
> save it as svg file eventually.
>
> Based on what I read, InkScape allows you to open wmf files. When I
> place WMF file in InkScape it closes and/or crashes.
>
> I have done open, import, and dragged WMF file into InkScape. The
> result is that InkScape closes without warning.
>
> Version info:
> =============
> I got InkScape (0.91 version) yesterday and believe that I have the
> latest version of it.
>
> Test case:
> ==========
> https://www.dropbox.com/s/22kxob0phnn73te/test12.wmf?dl=0
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/inkscape/+bug/1434721/+subscriptions
>

Revision history for this message
Alvin Penner (apenner) wrote :

I don't know for sure, but it is worth a try, I would suggest you just attach the dxf here and we can test it. The point is that dxf is a very common format which other programs such as QCad for example will also be able to open as well.

Revision history for this message
Alvin Penner (apenner) wrote :

just one more quick comment. I was able to load the svg file obtained from the emf, after a few minutes. When I chose the Inkscape menu item Edit->Select All it took a few minutes to respond, when it did respond, it said that I had selected 73,470 objects of type Path. This is a bit too much, so I suspect the original conversion to emf was deficient.

Revision history for this message
John Portnov (rocketscientist008) wrote :

Perhaps you are correct. I will email you AutoCad dxf version soon.

On Fri, Mar 27, 2015 at 10:06 AM, Alvin Penner <email address hidden> wrote:

> just one more quick comment. I was able to load the svg file obtained
> from the emf, after a few minutes. When I chose the Inkscape menu item
> Edit->Select All it took a few minutes to respond, when it did respond,
> it said that I had selected 73,470 objects of type Path. This is a bit
> too much, so I suspect the original conversion to emf was deficient.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1434721
>
> Title:
> Crash when opening WMF file
>
> Status in Inkscape: A Vector Drawing Tool:
> Confirmed
>
> Bug description:
> On 2015-03-20 14:16 (+0100), John Portnov asked this question:
> https://answers.launchpad.net/inkscape/+question/263913
>
> Original question:
> ==================
> I need to load my WMF File into InkScape so that I can work with it and
> save it as svg file eventually.
>
> Based on what I read, InkScape allows you to open wmf files. When I
> place WMF file in InkScape it closes and/or crashes.
>
> I have done open, import, and dragged WMF file into InkScape. The
> result is that InkScape closes without warning.
>
> Version info:
> =============
> I got InkScape (0.91 version) yesterday and believe that I have the
> latest version of it.
>
> Test case:
> ==========
> https://www.dropbox.com/s/22kxob0phnn73te/test12.wmf?dl=0
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/inkscape/+bug/1434721/+subscriptions
>

Revision history for this message
John Portnov (rocketscientist008) wrote :

Attached is the dxf file. This does not work because the colors and format
is not retained when the dxf is imported into InkScape. Perhaps it gets
lost in the process of saving dwg to dxf. In any case, this approach does
not work.

Thanks for the interesting suggestion,
John Portnov

On Fri, Mar 27, 2015 at 10:30 AM, John Port <email address hidden>
wrote:

> Perhaps you are correct. I will email you AutoCad dxf version soon.
>
> On Fri, Mar 27, 2015 at 10:06 AM, Alvin Penner <email address hidden> wrote:
>
>> just one more quick comment. I was able to load the svg file obtained
>> from the emf, after a few minutes. When I chose the Inkscape menu item
>> Edit->Select All it took a few minutes to respond, when it did respond,
>> it said that I had selected 73,470 objects of type Path. This is a bit
>> too much, so I suspect the original conversion to emf was deficient.
>>
>> --
>> You received this bug notification because you are subscribed to the bug
>> report.
>> https://bugs.launchpad.net/bugs/1434721
>>
>> Title:
>> Crash when opening WMF file
>>
>> Status in Inkscape: A Vector Drawing Tool:
>> Confirmed
>>
>> Bug description:
>> On 2015-03-20 14:16 (+0100), John Portnov asked this question:
>> https://answers.launchpad.net/inkscape/+question/263913
>>
>> Original question:
>> ==================
>> I need to load my WMF File into InkScape so that I can work with it and
>> save it as svg file eventually.
>>
>> Based on what I read, InkScape allows you to open wmf files. When I
>> place WMF file in InkScape it closes and/or crashes.
>>
>> I have done open, import, and dragged WMF file into InkScape. The
>> result is that InkScape closes without warning.
>>
>> Version info:
>> =============
>> I got InkScape (0.91 version) yesterday and believe that I have the
>> latest version of it.
>>
>> Test case:
>> ==========
>> https://www.dropbox.com/s/22kxob0phnn73te/test12.wmf?dl=0
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/inkscape/+bug/1434721/+subscriptions
>>
>
>

Revision history for this message
David Mathog (mathog) wrote :

Can you print from that application to PDF? Inkscape might be able to pull most of what you want out of that.

Rather than having us go on suggesting one file type at a time, let's just cut to the heart of the matter. The thing you need to do is to look at all the Inkscape Open types, and at the Autocad (or whatever this is) export/print types, and try all the types they have in common until you find one which works.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.