3

I want get rgb color some pixel in gif

from wand.image import Image
with Image(blob=img, format='JPG') as picture:
    print picture[1][1].string 
    # return srgb(0,0,0) is good

Problem:

from wand.image import Image
with Image(blob=img, format='GIF') as picture:
    print picture[1][1].string 
    # return srgb(93%,93%,93%) why?

2 Answers2

1

This is how color compliance works. Not all parts of the pixel in question can be represented as a 8-bit unsigned integer, so it's represented as a normalized percent -- between 0% and 100%.

Try the following...

from wand.image import Image
with Image(blob=img, format='GIF') as picture:
    picture.depth = 8
    print picture[1, 1].string
    #=> srgb(274,274,274)
emcconville
  • 23,800
  • 4
  • 50
  • 66
1

This is my code for png (python3)

from wand.image import Image

with Image(filename='white_background_320x200_edited_alphaoff.png') as img:
    print(img[1][1])
quine9997
  • 685
  • 7
  • 13