Pyxel Edit Forum Archive
ArchiveQuestions

convert folder (or .zip) to .pyxel file/archive

Bredjo
May 21, 2018 at 11:01 am
Hello everybody,

first of all @Danik thank you very much for creating Pyxel Edit. I really enjoy using it and it helps me a lot for my game development :smiley: 
 
To my question: Is there a way to convert a .zip archive to a .pyxel file/archive?
I know its possible to convert .pyxel archives to .zip archives by simply changing the file extension but I also need it the other way around. Simple renaming didn't do the job and when I try to create an archive with compressing program called WinRar (on Windows) a change the extension to .pyxel I get the following error when opening on Windows:




And on MacOS:



I'm asking because I use Pyxel Edit on my desktop PC and from now and then Pixaki on an iPad. So far, there is no way to transfer a file between both programs, which also contains the information of the layers.

In case of a simple drawing (no tiles or animation) I get from Pyxel Edit for each layer a .png file and a .json that contains all necessary information.
Regarding Pixaki I get a similar setup but with a .plist file instead of an .json file. I found a simple python script:
https://sourceforge.net/projects/plist2json/
to convert a .plist to a .json file and vice versa. So my workflow (Pixaki --> Pyxel Edit) is as follows:
  1. Getting the .pixaki file --> renaming it to .zip
  2. unpacking the .zip
  3. convert the invluded .plist file to .json
  4. pack the folder to a .zip archive
  5. ??? would like to transfer .zip to .pyxel ???
Is this even possible with the way I described?

All the best,
Bredjo
CandyFace
May 21, 2018 at 1:40 pm
Hi Bredjo

Are you packing the folder or the content of the folder? if you're doing the former, then that's most likely your problem. I've tried on mac os using "Keka" and I was able to zip the content, change the extension to .pyxel and load the file without issues.
Bredjo
May 22, 2018 at 3:40 pm
Hi CandyFace,
I packed the folder and I'll tried it with packing the content instead after I read your post but it didn't work either. The Error is still the same. But if you say this should work in principle, I will take a closer look into the python script.  Thank you very much for your help :smiley: 
 
CandyFace
May 22, 2018 at 8:33 pm
It's possible that the generated json differs from the json format PyxelEdit uses. Make sure the structure is identical.
Bredjo
May 30, 2018 at 4:17 pm
I created a small minimal example (same simple drawing for each program) and took a closer look at both preference files (.json and .plist). As you (@CandyFace) suspected there are a number of differences (color definition, order, preference names, etc.) between the two. Next, I will try to translate some basic preferences from .plist (Pixaki) to .json (PyxelEdit) by extending the python script.
Bredjo
May 30, 2018 at 4:51 pm
But in principle it works. When I switch the .png file with another one (with the same resolution), compress it to a .zip and rename it to .pyxel I get a working file, which shows the inserted .png file :). 
That means you could add the .png files and add the corresponding entry in the .json file as a temporary solution. Depending on the number of .png files this is quiet tedious and but than of course you lose all other preferences like your color palette.
If someone is interested, following the code snippet as example you need to add for each .png (layer) to the .json file:

"numLayers": 1,
"layers": {
      "0": {
        "tileRefs": {},
        "alpha": 255,
        "hidden": false,
        "name": "Layer 0",
        "blendMode": "normal"
      }      
  }

Place this code after the "tileHeight": 360, property and adjust the "numLayers" according to the number of layers/.png files you have)