inkstitch / pyembroidery

libembroidery/EmbroideryFormats converted to python
MIT License
71 stars 28 forks source link

pyembroidery cannto read vp3 files with true trim commands in them #74

Open MatsIBengtsson opened 4 years ago

MatsIBengtsson commented 4 years ago

When reading a vp3 file which contains true trims (trims which are not only a colour change), pyembroidery reads it wrong. This is also mentioned in Ink/Stitch (https://github.com/inkstitch/inkstitch/issues/516 and https://github.com/EmbroidePy/pyembroidery/issues/69)

As can be seen in below picture, a lot is missing. Both stitches and colours. To the left is Premier, to the right is the interpretation by Ink/Stitch (pyembroidery): Artboard 1

Enclosed are the files behind above views, containing the example, of a vp3 file which is fully readable in both Wilcom TrueSizer and Premier. But not in Ink/Stitch. It is collected as a zip (vp3 with trim.zip):

The example above is linked to the issue previously mentioned, #68 so the main stitch file is the same. One reason for this seem to be pyembroidery Vp3Reader. It assumes that all end points in a vp3-file is the end of the color_block, even if it is stated that there are more stitches in that colour block. A simple remedy is to remove that assumption (in vp3_read_colorblock remove the return following after the out command in "elif y == 0x03:". Doing that reads all the trimmed stitches into pyembroidery. Unfortunately, now the trims are missing (ignore the colour difference, my mistake):

output from inkstitch after removing return in vp3reader