Copy link to clipboard
Copied
Hi there,
I have to save 8 bit images with the following structure when converted to an array:
array([[[ 60, 124, 150, 255], [ 60, 124, 150, 255], [ 60, 124, 150, 255], ...,
But when I save as png 8 bit I obtain
array([[[115, 124, 67], [118, 127, 70], [122, 131, 76], ...,
Thank you!
Copy link to clipboard
Copied
Obviously, they are 2 different examples. I would need the 255 at the end of each single array!
Copy link to clipboard
Copied
I have no idea how you are going from Photoshop to PNG to this array data, but that is not the form used by PNG. In particular, PNG-8 does not contain a 2D array of RGB or RGBA values, one per pixel; that would be impossible, since you have only 8 bits per pixel. Rather it stores a 2D array of indexes. Each index looks up an RGB value (not RGBA). A PNG-8 file may additionally include a tRNS chunk, which gives transparency values for specific index values.
Copy link to clipboard
Copied
I used Python with PIL:
image_raw = np.array(Image.open('./image'))
Btw, it works with PNG-8 save for web.
Thank you!