Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


save image to be used as array 8 bit

New Here ,
Nov 16, 2021 Nov 16, 2021

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!

TOPICS
macOS

Views

38

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

Obviously, they are 2 different examples. I would need the 255 at the end of each single array!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 16, 2021 Nov 16, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

LATEST

I used Python with PIL:

image_raw = np.array(Image.open('./image'))

 

Btw, it works with PNG-8 save for web.

 

Thank you!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines