Topic: SkinMe script: convert old skins to the new format
Teeworlds 0.7 comes with an all-new skin system that is amazing. The only problem is that this system renders 0.6 skins completely useless. Over the years many skins have been created for 0.6 and it would be a shame to let those die off. So I decided to create this script that will run through your skins folder cut up all your 0.6 skins and convert them into 0.7 skins. Naturally, it would be better to recreate these old skins and migrate them to the new system. But as the community has thinned out not all skins will get this treatment. So this might be the best option for some.
All you have to do is place this script into the skin folder, make sure it is set as exhaustible and run it. It will check to see if you have the folders needed for the new system and if you don't will create them for you. Then it will loop through all the .pngs in the skin folder copy them to the various folders, crop, rearrange the skin, save them, and make you a skin.json file in your skin folder. The script will even make a backup of the old skins and place them into a "0.6 skins" folder for you in case you want to go back to the old version.
Depending on the skin the eyes may be a problem. so some eyes may still need to be modified manually.
#!/bin/bash
checkEnv () {
    if test ! -d "./body"; then
          mkdir body
    fi
    if test ! -d "./decoration"; then
          mkdir decoration
    fi
        if test ! -d "./eyes"; then
          mkdir eyes
    fi
        if test ! -d "./feet"; then
                    mkdir feet
        fi
    if test ! -d "./hands"; then
          mkdir hands
    fi
    if test ! -d "./marking"; then
          mkdir marking
    fi
        if test ! -d "./0.6_skins"; then
          mkdir 0.6_skins
    fi
}
stripBody() {
    cp $f "./body"
    cd "./body"
    convert $f -crop 96x96+0+0 -resize 128x128^ output.png
    convert $f -crop 96x96+96+0 -resize 128x128^ output2.png
    montage -geometry +1+1 output2.png output.png -background none output3.png
    mogrify -extent 256x256+0+0 -background none -strip output3.png
    cp output3.png $f
    rm output.png output2.png output3.png
    cd ..
}
stripEyes() {
    cp $f "./eyes"
    cd "./eyes"
    #Normal Eye
    convert $f -crop 24x32+64+96 normaleye.png
    convert $f -crop 8x32+64+96 space.png
    convert space.png normaleye.png +append -background none lefteye.png
    convert -flop lefteye.png righteye.png
    convert lefteye.png righteye.png +append -background none normal.png
    #Angry Eye
    convert $f -crop 24x32+96+96 angryeye.png
    convert space.png angryeye.png +append -background none lefteye.png
    convert -flop lefteye.png righteye.png
    convert lefteye.png righteye.png +append -background none angry.png
    #Hurt Eye
    convert $f -crop 24x32+128+96 hurteye.png
    convert space.png hurteye.png +append lefteye.png
    convert -flop lefteye.png righteye.png
    convert lefteye.png righteye.png +append -background none hurt.png
    #Happy Eye
    convert $f -crop 24x32+160+96 happyeye.png
    convert space.png happyeye.png +append -background none lefteye.png
    convert -flop lefteye.png righteye.png
    convert lefteye.png righteye.png +append -background none happy.png
    #Ninja Eye
    convert $f -crop 24x32+224+96 ninjaeye.png
    convert space.png ninjaeye.png +append -background none lefteye.png
    convert -flop lefteye.png righteye.png
    convert lefteye.png righteye.png +append -background none ninja.png
    #Merge Eyes
    convert normal.png angry.png +append -background none output3.png
    convert hurt.png happy.png +append -background none output4.png
    convert ninja.png space.png +append -background none output5.png
    convert output3.png output4.png -append -background none output6.png
    convert output6.png output5.png -append -background none output7.png
    convert output7.png space.png -append -background none output8.png
    convert output8.png -resize 120x120^ -strip output9.png
    cp output9.png $f
    #Clean Up
    rm normaleye.png normal.png angryeye.png angry.png hurteye.png hurt.png happyeye.png happy.png ninjaeye.png ninja.png lefteye.png righteye.png space.png output1.png output2.png output3.png output4.png output5.png output6.png output7.png output8.png output9.png
    cd ..
}
stripFeet() {
    cp $f "./feet"
    cd "./feet"
    convert $f -crop 32x32+208+32 -resize 64x64^ output.png
        convert $f -crop 32x32+208+64 -resize 64x64^ output2.png
        convert output.png output2.png +append -strip output3.png
    cp output3.png $f
    rm output.png output2.png output3.png
    cd ..
}
stripHands() {
    cp $f "./hands"
    cd "./hands"
    convert $f -crop 64x32+192+0 -resize 128x64^ -strip output.png
    cp output.png $f
    rm output.png
    cd ..
}
createSkin() {
    name=$(echo $f | cut -f 1 -d '.')
    echo "{\"skin\": {
        \"body\": {
            \"filename\": \"$name\",
            \"custom_colors\": \"false\"
        },
        \"hands\": {
            \"filename\": \"$name\",
            \"custom_colors\": \"false\"
        },
        \"feet\": {
            \"filename\": \"$name\",
            \"custom_colors\": \"false\"
        },
        \"eyes\": {
            \"filename\": \"$name\",
            \"custom_colors\": \"false\"
        }}
    }" > $name.json
}
moveskin() {
    cp $f "./0.6 skins"
}
deletSkin() {
    rm $f
}
checkEnv
for f in *.png; do
    stripBody
    stripEyes
    stripFeet
    stripHands
    createSkin
    moveskin
    deletSkin
done________________________________________________________________________________
License: GPL
TL;DR
CAN:                             CANNOT:            MUST:
Commercial Use          Sublicense            Include Original
Distribute                     Hold Liable            Disclose Source
Modify                                                        Include Copyright
Place Warranty                                          State Changes
                                                                  Include License
Note: I don't care too much about giving me credit or that you state changes as much as this copy right must stay with what ever is copied or modified.
Check out my DeviantArt for all my TeeWorlds art and ideas for Teeoworlds



 
						

