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

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/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])

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

Being the coordinates that indicate the area to copy

Convert from PIL Image

The paste() function will take the PIL Image object and will paste all of its content into the texture if theres enough space in the destination texture. Example:

from py3dst import Texture3dst
from PIL import Image

image = Image.open("path/to/image/")
texture = Texture3dst().new(image.size[0], image.size[1])
texture.paste(image, 0, 0)

paste() takes 3 arguments: image, x, y

x and y being the coordinates where the image will be pasted

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.0.2.tar.gz (45.3 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.0.2-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for py3dst-1.0.2.tar.gz
Algorithm Hash digest
SHA256 db95556ca2bd4ff44cd18ce0f9c8a01d90ecaa1e73ca0ea8fb59d2b34329fea1
MD5 145c84696df2ac6b86e5a6d3df18d386
BLAKE2b-256 8eb0eb2dd331750f0a60ad0dc5677ebd37ab88bdf1a3a30f612ce37e819b5657

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py3dst-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 33.2 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.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 91b3b2020704109d467325b00f8de3fb8baa334925f8d05a653367c702b46f96
MD5 5624f78911c7af917c25937b4e7b2e1a
BLAKE2b-256 965861b7cc86f1c913a2604e39a83b58a6f8c2f273dee0379ddebdcca6d77562

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