Xelawk / pkm2png

Convert PKM files to PNG images and back again.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pkm2png - Convert PKM files to PNG images

Installation

pkm2png requires the Python Imaging Library (documentation), which can be a very finicky installation. I suggest using pip to install it, since solutions to most installation errors can be found through a quick Google search.

Usage

Start by importing the module:

import pkm2png

From here, you can convert a PKM file:

my_pkm = open('/path/to/pokemonfile.pkm', 'r').read()
my_pkm_img = pkm2png.pkm2png(gen=5, data=my_pkm)
with open('/path/to/image.png', 'w') as f:
    f.write(my_pkm_img)

Or you can convert a PNG image:

# if on Windows, make sure to open in binary mode
my_pkm_img = open('/path/to/image.png', 'rb').read()
my_pkm = pkm2png.png2pkm(my_pkm_img)
with open('/path/to/pokemonfile.pkm', 'w') as f:
    f.write(my_pkm[1])

About

Convert PKM files to PNG images and back again.