N64Tex-Python
An image converter for N64 image formats written in Python
Description
This library is a Python implementation of Isotarge's N64Tex Tool
The goal is to have an OS-agnostic tool for converting between N64 image formats, fill in the missing CI image formats, and have a Python-importable library to function with my DK64-Lib Project
Installation
This package can be installed from PyPi using pip
pip install --upgrade n64tex
Usage
The package can be used in one of two ways. Either with the bundle CLI tool, or through a Python script itself.
CLI
From Image
Convert from an RGBA image to RGBA5551
n64tex rgba_image.png rgba5551 -o rgba5551_image.png
# Produces rgba5551_image.png
Optionally, you can also write a raw bytes file
n64tex rgba_image.png rgba5551 -o rgba5551_image.png --write_bytes
# Produces rgba5551_image.png and rgba5551_image
Converting to a CI format will provide an accompanying palette file
From bytes
You can also give a byte-like file to convert to an image, but the format must be specified
Converting from RGBA5551 to RGBA
n64tex rgba5551_bytes rgba5551 rgba -o rgba_image.png
# Produces rgba_image.png
Converting from CI bytes requires a bytes-like palette to be provided
n64tex ci8_bytes ci8 rgba -o rgba_image.png --palette palette_ci8_bytes
Python
Open an image and convert it to other formats
from PIL import Image
from n64tex.formats import RGBAImage
image = Image.open('rgba_image.png')
rgba_image = RGBAImage.from_image(image)
rgba5551_image = rgba_image.to_rgba5551()
i8a_image = rgba_image.to_i8a()
ci8_image = rgba_image.to_ci8()
# Any of these objects can be saves to an image file using the .save() method
rgba5551_image.save('rgba5551_image.png')
i8a_image.save('i8a_image.png')
ci8_image.save('ci8_image.png')
Open a bytes-like image and convert it to other formats or save it as an image file
from n64tex.formats import RGBA5551Image, CI8Image
with open('rgba5551_bytes', 'rb') as fil:
rgba5551_image = RGBA5551Image.from_bytes(fil.read(), width=32, height=32)
rgba5551_image.save('rgba5551_image.png')
# CI file formats require a palette
with open('ci8_bytes', 'rb') as fil, open('palette_ci8_bytes', 'rb') as palette_fil:
ci8_image = CI8Image.from_bytes(fil.read(), width=32, height=32, palette_bytes=palette_fil.read())
ci8_image.save('ci8_image.png')
Release files for n64tex 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| n64tex-1.0.1.tar.gz | 46.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| n64tex-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 86.6 kB
Release files / n64tex-1.0.1.tar.gz
| Download URL | n64tex-1.0.1.tar.gz |
|---|---|
| Size | 46.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c7ef6b94b9f17e4c0cdd15fb5850c30bce8c83d04eaefa725de32f4f19caa427
|
|
BLAKE2b-256 checksum How to use checksums |
8019994e4af581eb99036553fe246555a057ed84732050a927449d488ebdf015
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / n64tex-1.0.1-py3-none-any.whl
| Download URL | n64tex-1.0.1-py3-none-any.whl |
|---|---|
| Size | 40.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac76390380053df47067c41aea15e78db6b6fcf9a14eb06450a716daf1f3f66a
|
|
BLAKE2b-256 checksum How to use checksums |
8ddde6d10ff6926413852777360788fc4d3dad6eb146c056c29f66925af10654
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|