Closed EpicPuppy613 closed 3 years ago
Not all of those images are in RGB. Using the following modification to your code, you can see the modes of the images:
import os
from PIL import Image
for texture in os.scandir("textures\\block"):
if texture.path.endswith(".png"):
im = Image.open(texture.path)
print(im.mode, texture.path)
For example, attached_melon_stem.png
is a palette image (im.mode='P'
), while water_overlay.png
is grayscale with transparency (im.mode='LA'
). For what each mode value exactly means see the documentation.
If you would like to convert each image to RGBA, you can add the line im = im.convert("RGBA")
.
@EpicPuppy613 did that answer your question?
What did you do?
I created a program that scans all files in a directory, and averages all rgb values for each image
What did you expect to happen?
Image.load to return a PixelAccess object containing tuples
What actually happened?
Image.load returned a PixelAccess object containing integers
What are your OS, Python and Pillow versions?
I have not figured out why or when it happens so I have attached my entire workspace directory. image.zip