Skip to main content

Python module to read/edit 3DST textures.

Project description

py3dst is a module that allows to read, edit and convert 3DST textures

Installation

pip install py3dst

Command-line interface

The module has a simple command-line interface to perform certain tasks such as displaying the provided file on screen or other conversion tasks between formats

python -m py3dst -h

The previous command shows this help message

usage: py3dst [-h] [-c] [-r] [-f FORMAT] [-o OUT] [-v] [path]

Display or convert 3DST textures

positional arguments:
  path                  path to file to open and show        

options:
  -h, --help            show this help message and exit
  -c, --convert         indicates whether to convert the provided file
  -r, --recursive       convert files recursively in the directory
  -f FORMAT, --format FORMAT
                        (optional) color format for the output ('rgba8', 'rgb8', 'rgba5551', 'rgb565', 'rgba4', 'la8', 'la4')        
  -o OUT, --output OUT  destination file or directory if multiple output files
  -v, --version         show program's version number and exit

Supported formats:

  • RGBA8
  • RGB8
  • RGBA5551
  • RGB565
  • RGBA4
  • LA8
  • LA4

How to use

Open a texture

The open() function decodes and loads the texture at the provided path

from py3dst import Texture3dst

texture = Texture3dst().open("path/to/file")

Create a texture

The new() function allows to create a blank new texture

from py3dst import Texture3dst

texture = Texture3dst().new(128, 128)

new() takes 2 arguments: width, height

Optionally you can specify the 'mip_level' and 'format'

Export a texture

The export() function converts the data and writes the output data to the specified location

texture.export("path/to/out/file")

Convert to PIL Image

The copy() function will create an output of PIL Image type that you can then export to other image format

image = texture.copy(0, 0, texture.size[0], texture.size[1])
image.save("path/to/out/image/")

copy() takes 4 arguments: x1, y1, x2, y2

Being the coordinates that indicate the area to copy

Convert from PIL Image

The fromImage() function will take the PIL Image object and create a new texture with it. Example:

from py3dst import Texture3dst
from PIL import Image

image = Image.open("path/to/image/")
texture = Texture3dst().fromImage(image)

fromImage() takes 1 argument: image

image must be a PIL.Image object

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py3dst-1.1.1.tar.gz (47.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py3dst-1.1.1-py3-none-any.whl (35.0 kB view details)

Uploaded Python 3

File details

Details for the file py3dst-1.1.1.tar.gz.

File metadata

  • Download URL: py3dst-1.1.1.tar.gz
  • Upload date:
  • Size: 47.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for py3dst-1.1.1.tar.gz
Algorithm Hash digest
SHA256 fd1fcdee59cf3a8d6f03f75c256f94db2cc56099daed2a18c8c9652c88a359d1
MD5 8390d3c5aed8035bfed0f02a3f5ea061
BLAKE2b-256 2416465b608459e92aeb4d98a60cc721b0c7f6df773a68d13164f36f3382bf5a

See more details on using hashes here.

File details

Details for the file py3dst-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: py3dst-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 35.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for py3dst-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 64477c9c450fd0ec0a5c5f30b0ee9d38be156a5d118f632d2aca6b9f4fa2a334
MD5 b619d6c2dc31bca0d404fa761d6f9543
BLAKE2b-256 cab34ca890dee51fa3d6d69d49adff3b59dbed22ff326038a43dbc37d4425481

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page