Skip to content

Instantly share code, notes, and snippets.

@JamesKim2998
Created March 24, 2017 03:18
Show Gist options
  • Save JamesKim2998/a02ddfb0ead61f1a36d172bbaa6511a5 to your computer and use it in GitHub Desktop.
Save JamesKim2998/a02ddfb0ead61f1a36d172bbaa6511a5 to your computer and use it in GitHub Desktop.
Convert pvr file to png using TexturePacker.
#!/usr/local/bin/python3
import sys
import os
from glob import glob
from subprocess import call
def log(msg):
print('[PVR2PNG] ' + msg)
root = sys.argv[1]
log('Start: ' + root)
files = glob(root + '/**/*.pvr', recursive=True)
files.extend(glob(root + '/**/*.pvr.ccz', recursive=True))
files.extend(glob(root + '/**/*.pvr.gz', recursive=True))
for file in files:
log('Convert ' + file + '...')
filebase = file[:str.rfind(file, '.pvr')]
call(['TexturePacker', file,
'--sheet', filebase + '.png',
'--data', filebase + '.plist',
'--algorithm', 'Basic',
'--allow-free-size',
'--no-trim'])
log('Done')
@UnknownHobbyist
Copy link

Problems and Fixes for TexturePacker Lite Version

Problem/ Warnings
Those warnings result in PNG files with the Logo of TexturePacker.

TexturePacker:: warning: You are using TexturePacker in Essential (lite) mode.
TexturePacker:: warning:
TexturePacker:: warning: You are using some advanced features which will cause some sprites to
TexturePacker:: warning: be colored red in the sprite sheet.
TexturePacker:: warning:
TexturePacker:: warning: List of advanced features you are using:
TexturePacker:: warning:     - Extrude
TexturePacker:: warning:     - PngOptimization level not 0
TexturePacker:: warning:     - Detect identical sprites

Solution
Using following python code for the call.

call(['./TexturePacker.exe', file,
      '--sheet', filebase + '.png',
      '--data', filebase + '.plist',
      '--algorithm', 'Basic',
      '--allow-free-size',
      '--no-trim',
      '--extrude', '0',
      '--png-opt-level', '0',
      '--disable-auto-alias'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment