pngplist

I want to open the textures in the png file of a game that has plist and ExportJson files, but I couldn't do it


I wanted to examine the textures of a game I like on mobile. As far as I understand, the game textures were made with cocos2d. I have reversed the textures of other 2D games before, but I could not do this, please help.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>frames</key>
        <dict>
            <key>npc_alisa_arrange_black_01.png</key>
            <dict>
                <key>frame</key>
                <string>{{82,60},{22,32}}</string>
                <key>offset</key>
                <string>{-1,16}</string>
                <key>rotated</key>
                <false/>
                <key>sourceColorRect</key>
                <string>{{28,8},{22,32}}</string>
                <key>sourceSize</key>
                <string>{80,80}</string>
            </dict>
            <key>npc_alisa_arrange_black_02.png</key>
            <dict>
                <key>frame</key>
                <string>{{74,188},{22,30}}</string>
                <key>offset</key>
                <string>{-1,15}</string>
                <key>rotated</key>
                <false/>
                <key>sourceColorRect</key>
                <string>{{28,10},{22,30}}</string>
                <key>sourceSize</key>
                <string>{80,80}</string>
            </dict>
            <key>npc_alisa_cooking_black_01.png</key>
            <dict>
                <key>frame</key>
                <string>{{34,84},{22,36}}</string>
                <key>offset</key>
                <string>{-1,17}</string>
                <key>rotated</key>
                <false/>
                <key>sourceColorRect</key>
                <string>{{28,5},{22,36}}</string>
                <key>sourceSize</key>
                <string>{80,80}</string>
            </dict>
            <key>npc_alisa_cooking_black_02.png</key>
            <dict>
                <key>frame</key>
                <string>{{66,2},{22,38}}</string>
                <key>offset</key>
                <string>{-1,18}</string>
                <key>rotated</key>
                <false/>
                <key>sourceColorRect</key>
                <string>{{28,3},{22,38}}</string>
                <key>sourceSize</key>
                <string>{80,80}</string>
            </dict>
            <key>npc_alisa_cooking_black_03.png</key>
            <dict>
                <key>frame</key>
                <string>{{2,126},{22,36}}</string>
                <key>offset</key>
                <string>{-1,17}</string>
                <key>rotated</key>
                <false/>
                <key>sourceColorRect</key>
                <string>{{28,5},{22,36}}</string>
                <key>sourceSize</key>
                <string>{80,80}</string>
            </dict>

I tried with classic textureunpackers but I was not successful. Normally they open easily but I keep getting errors.


Solution

  • If you hex-dump your PNG file, it looks like this:

    xxd npc_alisa.png | more
    
    00000000: 0050 4e47 0d0a 1a0a 5000 000d 4948 4452  .PNG....P...IHDR
    00000010: 0000 0100 0000 00f4 0803 0000 0043 d808  .............C..
    00000020: ef00 0000 0467 414d 4100 00b1 8f0b fc61  .....gAMA......a
    

    The "file magic" (a.k.a. signature) of a PNG file is:

    89 50 4e 47 0d 0a 1a 0a
    

    so the first byte is corrupted. You can either edit it with a hex-editor, or if you are a dinosaur like me, use xxd to dump it in plain ASCII, then use sed to change the first byte from 00 to 89 and then re-assemble the binary PNG from plain ASCII:

    That looks like this:

    xxd -p npc_alisa.png | sed '1s/00/89/' | xxd -r -p > patched.png
    

    If you try and use that file, you'll get an error because the length field of the IHDR chunk is set to 50 00 00 0d which is an enormous number which will make PNG readers try and read 1342177293 bytes of IHDR and fall off the end of the file. The correct length of an IHDR is 13 bytes, so it should be 00 00 00 0d. So, I get out trusty old xxd and sed and change that too:

    xxd -p npc_alisa.png | sed -e '1s/00/89/' -e '1s/1a0a50/1a0a00/' | xxd -r -p > patched.png
    

    enter image description here


    Note that if you don't have/like xxd and sed, you can use a hex editor. This is not an endorsement, and I have no affiliation, but there is a fairly decent online one here which means you don't have to install anything on your machine and it works for hapless Windows users too.