Page MenuHome

bpy.image['name'].pixels[0] shows wrong value
Closed, ArchivedPublic

Description

System Information
Operating system: ubuntu 18.04

Blender Version
Broken: 2.79b

Short description of error
Same image saved with different depths has different values printed with bpy.image['name'].pixels[0] (much more than could be caused with changing depth).

Exact steps for others to reproduce the error

  1. open attached test.blend
  2. paste to console:
bpy.image['test8.png'].pixels[0]
bpy.image['test16.png'].pixels[0]
  1. notice that output is 0.7372549176216125 and 0.5000087022781372 respectively, but images don't differ so much


Don't worry if you don't notice images, their size is 1x1

Details

Type
Bug

Event Timeline

Sebastian Parborg (zeddb) triaged this task as Confirmed, Medium priority.

I can confirm this on 2.8 too.

You will get the same value if you change the color management setting to Raw.

@Brecht Van Lommel (brecht) Does this fall in with T54659 as the rest of the 16bit problems?

Brecht Van Lommel (brecht) claimed this task.

It's not really related to that. It's a weirdness in the API which we should improve once, but outside the scope of the bug tracker.

Blender loads 8-bit images in a byte buffer to keep memory low, without color space conversion. Higher bit depth images are always converted to scene linear color space in a float buffer.

So what you have are pixels in two different color spaces. image.is_float can be used to detect which type of image it is.