Load an image with PIL

PHOTO EMBED

Fri Nov 18 2022 19:29:03 GMT+0000 (Coordinated Universal Time)

Saved by @MaVCArt #python

import numpy as np
from PIL import Image

path = 'res/input.tga'
img = Image.open(path)

data = np.asarray(img.convert('L'))

# -- this will print the resolution of the image in pixels, as numpy converts our image to an
# -- array with dimensions equal to the number of pixels in width / height of the image.
print(data.shape)
content_copyCOPY