Implement libsai for importing PaintTool Sai files.
Open, WishlistPublic


So, Sai has for some indeterminable reason(proly cultural) a heavily encrypted file format. Wunkolo on github/gitlab has been trying to decipher this format and made 'libsai' with the efforts. We should see how difficult it is to get this working in Krita, so users can open their old painttool sai files.

From the 2019 sprint, @rempt and wolthera sat down to figure out how difficult it is to add the library. Boud came to the conclusion it'll take a bit of effort to get it working on Krita given libsai is 1. C++14, and 2. threw a bunch of errors when we tried to compile it as part of Krita.


  • Rework importer to use new libsai stuff.
    • Groups
    • Raster data
    • Clipping layers.
    • Masks creation.
  • Textures and layer styles.
  • Creating vector layers
  • Support Binary blending mode(not much work, hour or 2 at most)
  • Implement setting the background
  • Handle resolution.
  • Working with Wunkolo to create a simple svg interpreter for vector stuff.
  • Work with Wunkolo to figure out the mystery raster data.
  • Load masks - will need to come back to this later, masks are more complex than they seem...
woltherav triaged this task as Wishlist priority.
rempt added a comment.Aug 29 2019, 8:56 AM

Note: libsai has hardcoded AVX support depending on whether the build machine has AVX.

woltherav added a comment.EditedAug 29 2019, 3:26 PM

Alright, today...

  • did basic interfacing with the library, we can open a document of the appropriate size.
  • tried to figure out how I can get to the layer data.
  • read libsai's readme real hard
  • made test files :)

Current state is that while I can sort of program my way into getting layer data (right now have some debug setup, and for the rest of the layer stuff we can do the same thing we use for other binary files like acs, psd and some of the gimp files), it might be better to implement that part into libsai:

Found a crash/lockup with one of my old files:

Wunkolo also says he's interested in documenting the linework/vector layer, so that's pretty cool:

[spam comment removed by sysadmin]

[spam comment removed by sysadmin]

Got basic layer properties loading done :)

Ok, I figured out a few more tags through the power of test files;

And I started working on the pixeldata decryption, which is very crashy atm, and asked for more help there..

It still crashes on actual sai files, but that's being investigated :)

woltherav updated the task description. (Show Details)Sep 9 2019, 12:50 PM
woltherav updated the task description. (Show Details)
woltherav updated the task description. (Show Details)Sep 10 2019, 2:41 PM
woltherav updated the task description. (Show Details)Sep 10 2019, 3:49 PM
woltherav updated the task description. (Show Details)Sep 10 2019, 4:15 PM