We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The alpha channel is always set to 255, even if I specify backround to be [... , 4].
import trimesh import numpy as np import PIL.Image as Image mesh = trimesh.creation.cone(radius=1, height=1) scene = trimesh.Scene([mesh]) scene.set_camera(resolution=(100, 100)) image_data = scene.save_image(background=[1, 2, 3, 4]) # alpha value of backgound should be 4 image = Image.open(io.BytesIO(image_data)) image = np.array(image) print(np.unique(image[..., 3])) # shows [255] instead of [4]
I'm running this on WSL2 / Ubuntu 22.04.5 LTS. Python version 3.10.12
numpy pillow trimesh[all]
sudo apt-get update sudo apt-get install freeglut3 freeglut3-dev libglu1-mesa-dev pip install -r requirements.txt (inside venv)
The text was updated successfully, but these errors were encountered:
Can't reproduce with:
# Python 3.10.11 trimesh==4.5.1 pillow==10.4.0 numpy==1.26.4
Using (screenshots bad, text good):
import trimesh import numpy as np import io from PIL import Image mesh = trimesh.creation.cone(radius=1, height=1) scene = trimesh.Scene([mesh]) scene.set_camera(resolution=(100, 100)) image_data = scene.save_image(background=[1, 2, 3, 4]) with open('scene.png', 'wb') as f: f.write(image_data) image = Image.open(io.BytesIO(image_data)) image = np.array(image) print(np.unique(image[..., 3]))
I get [ 4 67 129 192 255], and confirmed that "scene.png" has a transparent background, in an image editor.
[ 4 67 129 192 255]
Sorry, something went wrong.
I've also run into this and could fix it by setting alpha_size=8 in the pyglet config like so e.g.:
alpha_size=8
from pyglet import gl scene.save_image(..., window_conf=gl.Config(sample_buffers=1, samples=4, depth_size=24, double_buffer=True, alpha_size=8))
It seems that it defaults to alpha_size=0 in my headless environment, which of course prevents the alpha channel from working.
alpha_size=0
No branches or pull requests
Issue description:
The alpha channel is always set to 255, even if I specify backround to be [... , 4].
Minimal reproducible example:
System:
I'm running this on WSL2 / Ubuntu 22.04.5 LTS.
Python version 3.10.12
requirements.txt:
My setup:
The text was updated successfully, but these errors were encountered: