• Runtimes
  • How to cancel the premultiplied alpha when unpacking the CLI?

How to cancel alpha when unpacking using the command line interface (CLI)?

Related Discussions
...

The unpacker uses the atlas page pma setting. You can modify and remove the pma setting in the atlas file or set it to false.

  • yugutou ha risposto a questo messaggio

    Nate
    Am I looking in the wrong place? I didn’t find pma

    There's two versions of the atlas format. Spine and all the 4.0+ runtimes can parse either versions. Older runtimes can only parse the old version. New versions of Spine can write the old version by checking Legacy output in the packer settings.

    You've shown the old version. The new version looks like:

    mix-and-match-pro.png
    size:2048,256
    filter:Linear,Linear
    pma:true
    scale:0.5
    base-head
    bounds:652,90,95,73
    boy/arm-front
    bounds:243,67,36,115
    ...

    The pma:true can be omitted if false. You can add it to your atlas file, then use the 4.0+ unpacker to unpack and it will unpremultiply the alpha.

    • yugutou ha risposto a questo messaggio

      Nate Thank you for your answer, I have fully understood premultiplied alpha, now I have another question, could you please show me how to check the checkbox [unpremultiply alpha] by using command line interface (CLI) during the process of unpacking texture which packed with premultiplied alpha,I will directly delete the pam in Atlas: true doesn't work

      Using the Spine UI, the unpacker uses the value of pma in the atlas file if it exists. If it does not exist, then the unpacker uses the checkbox.

      Using the CLI, the unpacker uses the value of pma in the atlas file. If it does not exist, the unpacker does not perform un-premultiplication. There is not a way to force it to do it or not do it, except pma:true or pma:false in the atlas file (or nothing in the atlas file, which is the same as pma:false).

      Please note you should use the latest (4.1+) version of Spine to do the unpacking. Older versions make not work as described. For example, before 4.0 the pma value in the atlas file is not used. Plus an old version of Spine may not be able to parse the newer atlas file format.

      • yugutou ha risposto a questo messaggio

        Nate Thank you for your answer. I have another question that I would like to receive your help with. When I use the following code for Spine restore, the resulting image path is an absolute path. If I want to obtain the relative path, how can I modify it? Please forgive me for asking too many questions

        echo.
        set /p var=the spine [scale] is 
        echo =========================================================
        echo.
        echo Starting, please wait...
        echo.
        set /a sum1=0
        set /a sum2=0
        
        @echo off
        for /f "usebackq tokens=*" %%d in (`dir /s/b *.json`) do (set /a sum1=sum1+1
        "D:\Spine\Spine.exe" -i "%%d" -o "%%~dd%%~pd%%~nd.spine" -s %var% -r "%%~nd"
        echo "%%~nd.spine"  Done 
        )
        
        
        for /f "usebackq tokens=*" %%d in (`dir /s/b *.skel`) do (set /a sum2=sum2+1
        "D:\Spine\Spine.exe" -i "%%d" -o "%%~dd%%~pd%%~nd.spine" -s %var% -r "%%~nd"
        echo "%%~nd.spine"  Done 
        )
        @echo off
        set /a total=sum1+sum2
        echo =========================================================
        echo.
        echo Done json: %sum1%  skel: %sum2% total: %total%
        echo.
        echo =========================================================
        pause```
        • Modificato

        Windows batch scripts are always so hard to read. FWIW, I prefer to use Cygwin. You can just install using the defaults, then put Cygwin's bin folder on your Windows PATH. That lets you use Linux commands like ls at the Windows command prompt, and you can run Bash scripts. Those are still pretty difficult but much better than Windows batch scripts. For example, here is one of our export Bash scripts:
        https://github.com/EsotericSoftware/spine-runtimes/blob/4.1/examples/export/export.sh
        To run it without Cygwin you'd use sh export.sh.

        Anyway, it looks like you are doing -i x -o y -r z which is importing JSON data files into Spine project files. The Skeleton loaded from the JSON data has an imagesPath, which in JSON is images on the skeleton. During import that will be used for the images path in the Spine project. If no folder at that path exists, Spine will use the parent folder of the JSON file + that path, if that exists. If no images path is set in the JSON data, then the parent folder of the JSON file is used for the images path.

        After the above, the images path is made relative using the same rules as if you pasted a path into the Spine UI and pressed enter. That is, a relative path is used if the images path is within 3 parents of the project folder. The parent folder of the JSON file is considered the project folder.

        Sorry if that technical description seems a bit confusing. Maybe I should just show what the editor code does during import:

        skeleton.imagesPath = skeletonData.getImagesPath();
        if (skeleton.imagesPath == null) skeleton.imagesPath = projectDir;
        if (!skeleton.imagesPath.exists()) {
        	var relative = jsonFile.parent().child(skeleton.imagesPath);
        	if (relative.exists()) skeleton.imagesPath = canonicalPath(relative);
        }
        skeleton.updateImagesPath(); // Makes the path relative if within 3 parents of the project path.

        In plainer language, we don't have a way to set the images path explicitly. You'll want to move the JSON file into the project folder and import it from there. If you have exported your skeletons with nonessential data, that may be sufficient for your imported Spine projects to have the correct relative images path.

        If there is no images path in your JSON, then your images path will be set to the project folder. If that is not what you want, you could modify the JSON to add the images path, possibly with a script. This will probably be difficult with a Windows batch script. With Cygwin you can write a Bash script and use Linux commands, so you could use sed for example to replace text in a file:

        sed 's/word1/word2/g' skeleton.json

        You could replace skeleton: { with skeleton: { images: "your/path",. Really though, once your shell script starts getting complex, it may be better to change to an actual programming language, like Java, Perl, Python, or whatever you are most familiar with.

        • yugutou ha risposto a questo messaggio

          Nate
          I like your careful answer. May I know when Spine4.2 plans to be launched? We have been looking forward to experiencing this feature for too long

          • Nate ha messo mi piace.

          Glad it helped!

          We have had some unexpected delays, sorry. We hope to start the 4.2 beta in a couple weeks.