Support PES embroidery file format

Bug #247463 reported by Ryan Lovett
42
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Inkscape
In Progress
Wishlist
Unassigned

Bug Description

(This bug is a followup to https://bugs.launchpad.net/bugs/171451)

I am interested in seeing the PES/PEC embroidery file format supported by inkscape. My mom has a machine that uses the .PES file format and half dozen or so proprietary Windows programs that can either read or convert to/from .PES. I'd never tried reverse engineering a file format before and didn't get very far with this, but I'm eager to try with a little help.

I asked Brother for file format details without success.

There is some information about the file format at these pages:
http://www.softhelp.ru/fileformat/pes/pes.htm
http://www.achatina.de/sewing/main/TECHNICL.HTM

This page has free (beer) Windows software for viewing and converting PES files.
http://www.joachim-riedel.de/freeware/
PesView works under wine.

Revision history for this message
Ryan Lovett (ryan-spacecoaster) wrote :
Revision history for this message
Ryan Lovett (ryan-spacecoaster) wrote :
Revision history for this message
Ryan Lovett (ryan-spacecoaster) wrote :
Revision history for this message
Ryan Lovett (ryan-spacecoaster) wrote :
Revision history for this message
Ryan Lovett (ryan-spacecoaster) wrote :
Revision history for this message
Ryan Lovett (ryan-spacecoaster) wrote :
Revision history for this message
Ryan Lovett (ryan-spacecoaster) wrote :
Revision history for this message
sas (sas-sas) wrote :

I found a free (GPL) PES viewer at http://www.njcrawford.com/embreader/ (currently Windows only). It includes some incomplete documentation of the PES file format, but much more can be deduced from reading the C# source code (which apparently fully supports #PES0001, which is what most PES files that I've seen are).

Revision history for this message
Ryan Lovett (ryan-spacecoaster) wrote :

I bow to your google-fu. Thanks for the link! I'll check it out.

Revision history for this message
Robert Heel (2-launchpad-net-bobosch-de) wrote :

Would be a nice feature ...
Also some free files on the brother homepage: http://www.brother-usa.com/HomeSewing/GetCreative/free-designs.aspx

Revision history for this message
Ryan Lovett (ryan-spacecoaster) wrote :

I wrote a Cocoa app (Obj C) based on the code at the link provided by sas.

http://code.google.com/p/needleworks/

What is the right way to go about developing import support for inkscape? Write a PES -> SVG program?

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

    Probably the place to start would be to look at some of the Python files in the directory \Inkscape\share\extensions\.
    These run either from the Effects menu or as import/export procedures.

Revision history for this message
Robert Heel (2-launchpad-net-bobosch-de) wrote :

I've created a php version based on crawford's code:
http://bobosch.dyndns.org/embroidery/showFile.php?pes.php

Revision history for this message
Robert Heel (2-launchpad-net-bobosch-de) wrote :

My inkscape extension works :-)

Install php5-cli and extract these files to ~/.inkscape/extensions/

Revision history for this message
Ryan Lovett (ryan-spacecoaster) wrote : Re: [Bug 247463] Re: Support PES embroidery file format

On Tue, Jan 27, 2009 at 08:52:30PM -0000, Robert Heel wrote:
> My inkscape extension works :-)

Yes it does! Thanks Robert!

Ryan

Revision history for this message
waclark57 (waclark57) wrote :

My question is does this extension save files as PES files or simply convert from PES to SVG? It would be great to be able to create and save files as PES files to be used on the embroidery machine. I can test on my wife's machine if we get that far.

Thanks
TC

Revision history for this message
Alexandre Prokoudine (alexandre-prokoudine) wrote :

Wow, two possible contributors to mainstream and we miserably failed noticing you! Sorry guys!

@Ryan Lovett & Robert Heel. Ideally a convertor should be written in Python and available as part of UniConvertor project so that not just Inkscape benefits from it.

http://sk1project.org/modules.php?name=Products&product=uniconvertor

Revision history for this message
waclark57 (waclark57) wrote :

Another question. Where is the .inkscape folder on a Windows machine? I see an extensions folder under the inkscape program install folder but putting the files there doesn't seem to work for me.

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

the extensions would be in the directory
C:\Program Files\Inkscape\share\extensions

The files posted here are an import routine to convert .pes into .svg.
If I use the menu item File | Import then there is a file type called :
Brother embroidery design (*.pes)

If I try to open a file type .pes then it crashes because I do not have a php interpreter installed. It would be nice to see this written in Python.

Revision history for this message
waclark57 (waclark57) wrote :

OK, got the files into the correct folder and have the PHP interpreter for Windows. PES files come into Inkscape just fine! Yee Haw!!!

Now, how about writing PES files?

I can see that writing PES fomat might be a non-trivial task. For one thing, in the Imported files you can see that the "fill" areas are actually individual stitching lines which is what you would expect for an embroidery object. I think we will need an external program that would "fill" an area in Inkscape with stitching lines instead of the usual paint bucket fill. You would probably need to be able to specify the density of the stitches and the maximum (and minimum) stitch length.

I think we're close, though. If we can read the format surely we can write it back out???

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

I just installed php and got the import routine to work.
Congratulations, Robert, very nicely done!

tags: added: import-export
Revision history for this message
Pablo Trabajos (pajarico) wrote :

I'm setting this as In Progress because it seems to read it but not write it. However, the current 0.47pre4 doesn't include it.

Changed in inkscape:
importance: Undecided → Wishlist
status: New → In Progress
Revision history for this message
max (maxim-s-barabash) wrote :

I am ready to add the import of this and other similar formats in uniconvertor.
But the import of these formats without exports is useless.
What are the plans to export?

Revision history for this message
Robert Heel (2-launchpad-net-bobosch-de) wrote :

Not completely useless - you see what's in the file ...

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

- agreed, absolutely, I think the rule to follow here is : "Never look a gift horse in the mouth"
- with respect to the problem of output, this will probably be significantly more difficult, because it will probably require a user-interface and configurable options, as mentioned in comment 20.

Revision history for this message
max (maxim-s-barabash) wrote :

I added import filters for DST and SPE files in sK1.
http://sk1.svn.sourceforge.net/viewvc/sk1/trunk/sK1/src/app/plugins/Filters/stitchloader.py?view=log
After some time, these filters get into uniconvertor.

Please test.

Revision history for this message
max (maxim-s-barabash) wrote :

Is very slow rendering PES file, containing 25 000 nodes, .
Unfortunately, this can be a problem for making layouts embroidery in Inkscape.

In the attached files for integration into inkscape.

Revision history for this message
Aron Rubin (aronrubin) wrote :

I just wanted to indicate support for both import and export here. If there is anything a programmer not familiar with Inkscape plugin API or sK1 can do please let me know. I would think we would need to know more about best practices in embroidery. Specifically how to stitch a solid field, max and min ranges of a stitch. This seems like a job for Voronoi tesselation.

Revision history for this message
Oldřich Jedlička (oldium) wrote :

Maybe Anne Wilson http://lydgate.org/blogs/ would be interrested if you need help (as a user), I've just read her article on PlanetKDE.

Revision history for this message
Mikael Öhlin (micke-onsdag) wrote :

Hi I'm very interested in this subject, mostly because the programs I use at work really are hard to learn and jumping between screens, measures changes by itself and so on, I think that we could make a better program for embroidery in linux and I promise to help with what I can and learn some on the way too.

Revision history for this message
Felipe "Juca" Sanches (felipe-sanches) wrote :
Revision history for this message
Mikael Öhlin (micke-onsdag) wrote :

Me too, although I am a beginner when it comes to python programming, I try
to learn while experimenting. ;-)

2010/2/12 Felipe "Juca" Sanches <email address hidden>

> Linus Torvalds is working on it :-)
>
> http://torvalds-family.blogspot.com/2010/01/embroidery-gaah.html
>
> --
> Support PES embroidery file format
> https://bugs.launchpad.net/bugs/247463
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Inkscape: A Vector Drawing Tool: In Progress
>
> Bug description:
> (This bug is a followup to https://bugs.launchpad.net/bugs/171451)
>
> I am interested in seeing the PES/PEC embroidery file format supported by
> inkscape. My mom has a machine that uses the .PES file format and half dozen
> or so proprietary Windows programs that can either read or convert to/from
> .PES. I'd never tried reverse engineering a file format before and didn't
> get very far with this, but I'm eager to try with a little help.
>
> I asked Brother for file format details without success.
>
> There is some information about the file format at these pages:
> http://www.softhelp.ru/fileformat/pes/pes.htm
> http://www.achatina.de/sewing/main/TECHNICL.HTM
>
> This page has free (beer) Windows software for viewing and converting PES
> files.
> http://www.joachim-riedel.de/freeware/
> PesView works under wine.
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/inkscape/+bug/247463/+subscribe
>

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

    Attached is a summary of what I have seen with respect to support of PES files. There are potentially three issues that need to be addressed: loading, editing and outputting. The editing and outputting are much more difficult than loading, and I am not aware of anyone who is working on them, at least not from inside Inkscape as a platform.
    There are currently two methods available for loading, both of which appear to work very well, but neither is currently available in the Inkscape trunk for general use.
    Method 1 - php script by Robert Heel (comment 14 above). To install this, copy the three files in the archive to the directory \Inkscape\share\extensions\ and install php5-cli support.
    Method 2 - Python script in uniconvertor (comment 27 above, by max). To install this, unzip stitchloader.zip and copy the file stitchloader.py to the directory (on Windows) \Inkscape\python\Lib\site-packages\uniconvertor\app\plugins\Filters\ and copy the file pes_input.inx to the directory \Inkscape\share\extensions\.

    I have just finished testing both methods and they both work equally well, as far as I can see. The .svg files they produce appear to be structurally identical. The only difference I can see is in the units. The php script uses the original coordinates, which were integers, and copies them unchanged into the .svg file. The uniconvertor script generates floating point .svg coordinates using the conversion factor 72/254. This is equivalent to stating that the .pes file was in units of 0.1 mm and the output .svg file is in units of points. In the case of Inkscape .svg it would be more appropriate to use 90/254 instead, because the Inkscape default unit is pixels at 90 dpi.

   The only serious difference between them is in the installation procedure. The uniconvertor plugin has the advantage of being written in Python, but it is not yet officially included in uniconvertor, so it must be installed manually. The php script could easily be added to the Inkscape trunk, but would require the separate installation of php support.

    Any preferences?

Revision history for this message
Mikael Öhlin (micke-onsdag) wrote :
Download full text (4.3 KiB)

I began trying to translate Robert Heel's php script to python but I'm a
beginner in python so I didn't come very far until I came into trouble, and
I think I must learn how to read a PES file first, before I can do anything
with it. I think it would be a good idea to ask the user for the prefered
size of the embroidery since most embroidery machines support a couple of
different sized frames that keep the fabric stretched during embroidery,
fitting the frames correct on a t-shirt or a pair of pants is in itself a
problem since the frames are always bigger than the embroidery, and on
jackets pockets tend to appear where customers want their embroidery.

It is also a good idea to have at least 1 mm width to a line as smaller
lines tend to sink into the fabric even though we use plastic on top of the
fabric, we have tried lowering the thread tension but it didn't help much.
Anyway I'm very glad for the response and I think that we will figure out
solutions eventually.
Mikael Öhlin.

2010/2/13 Alvin Penner <email address hidden>

> Attached is a summary of what I have seen with respect to support of PES
> files. There are potentially three issues that need to be addressed:
> loading, editing and outputting. The editing and outputting are much more
> difficult than loading, and I am not aware of anyone who is working on them,
> at least not from inside Inkscape as a platform.
> There are currently two methods available for loading, both of which
> appear to work very well, but neither is currently available in the Inkscape
> trunk for general use.
> Method 1 - php script by Robert Heel (comment 14 above). To install
> this, copy the three files in the archive to the directory
> \Inkscape\share\extensions\ and install php5-cli support.
> Method 2 - Python script in uniconvertor (comment 27 above, by max). To
> install this, unzip stitchloader.zip and copy the file stitchloader.py to
> the directory (on Windows)
> \Inkscape\python\Lib\site-packages\uniconvertor\app\plugins\Filters\ and
> copy the file pes_input.inx to the directory \Inkscape\share\extensions\.
>
> I have just finished testing both methods and they both work equally
> well, as far as I can see. The .svg files they produce appear to be
> structurally identical. The only difference I can see is in the units.
> The php script uses the original coordinates, which were integers, and
> copies them unchanged into the .svg file. The uniconvertor script
> generates floating point .svg coordinates using the conversion factor
> 72/254. This is equivalent to stating that the .pes file was in units of
> 0.1 mm and the output .svg file is in units of points. In the case of
> Inkscape .svg it would be more appropriate to use 90/254 instead,
> because the Inkscape default unit is pixels at 90 dpi.
>
> The only serious difference between them is in the installation
> procedure. The uniconvertor plugin has the advantage of being written in
> Python, but it is not yet officially included in uniconvertor, so it
> must be installed manually. The php script could easily be added to the
> Inkscape trunk, but would require the separate installation of php
> support.
>
> Any preferences?
>...

Read more...

Revision history for this message
max (maxim-s-barabash) wrote :

In sK1 added filters import for:
DST (Tajima) Design format
PES (Brother) Embroidery file format
EXP (Melco) Embroidery file format
PCS (Pfaff home) Design format
They will be available in the next release Uniconvertor.

Scheme of work now looks like this:
Filter PES -> Uniconvertor -> filter SVG -> Inkscape
There is an assumption that the problem in the filter SVG.
I do not have the embroidery machines and can not verify the scaling.

If you have the specifications and examples of other file formats I am ready to add them.
Comments, suggestions and assistance is also accepted.

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

    thanks max, glad to hear that this will be in Uniconvertor. As to scaling that is probably not a serious issue, I believe the scaling is currently being redefined, according to Bug 387946. For my own calculations, what I did was read the .pes file directly using a hex reader to get the coordinates as integers and then compared them to the .svg output file to confirm the scale.
    So I suggest we wait for the release of Uniconvertor 1.1.5 and then re-evaluate the status at that time. Currently there is enough code available that anyone who wishes to perform a temporary patch can easily do so.

Revision history for this message
jonh (jonh-launchpad) wrote :

I've written an Inkscape extension that emits an embroidery file format (.EXP), which I then convert to .PES to use with my Brother machine. Try it out from here: <a href="http://www.jonh.net/~jonh/inkscape-embroidery/">http://www.jonh.net/~jonh/inkscape-embroidery/</a>

Revision history for this message
James Baldassari (jbaldassari) wrote :

@johnh I tried your Inkscape extension but couldn't get it working:

Traceback (most recent call last):
  File "~/.config/inkscape/extensions/embroider.py", line 19, in <module>
    import PyEmb
ImportError: No module named PyEmb

I couldn't find the PyEmb module anywhere.

Revision history for this message
David Armstrong (armstrong360) wrote :

Jonh has uploaded a new tar file which includes the PyEmb.py file. I am trying to use it with Inkscape to produce digitized fonts for embroidery.

Revision history for this message
Trever Adams (trever-adams) wrote :

All of you who are at all interested in actually writing pes files, I have created a new project. For the moment it is a document only. I would love help filling in the unknown peices. I have tried to pull together, verify, and expand all of the PES documentation I can find. Some of it I didn't find until I had already figured it out, others helped me a great deal. I would love all the help I can get.

https://github.com/treveradams/libpes

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.