PIL im.getdata file format
Question: I'm new for Python, so sorry for stupid question. When I call for
list(im.getdata()) the result looks like a list with triple-tuple inside.
Simple list commands such as sum() doesn't want to work, claiming:

    
    
    Traceback (most recent call last):
      File "C:\Users\Poos\Desktop\G\SS.py", line 8, in <module>
        y = sum(x)
    TypeError: unsupported operand type(s) for +: 'int' and 'tuple'
    

What should I do to operate with this data as with a "normal" list? Thanks and
sorry for English inaccuracies


Answer: The list returned is the RGB value for each pixel, so each element _should_ be
a tuple with three elements. I don't know what you want to accomplish by
summing the elements. If you want to determine the 'total red component', you
can use list comprehension:

    
    
    red = sum([x[0] for x in list(im.getdata())])
    

Maybe we can help you better if you better describe what you want to achieve.

**Equivalence**

Edit after first comment: if you want to check if two images are _equal_ ,
then you can compare the data, or the images directly.

    
    
    >>> a = [(1,2,3), (4,5,6)]
    >>> b = [(1,2,3), (4,5,6)]
    >>> a == b
    True
    
    >>>> from PIL import Image
    >>> a = Image.new("RGB", (250,250), "red")
    >>> b = Image.new("RGB", (250,250), "red")
    >>> a == b
    True
    >>> b.putpixel((100,100), (100,100,100))
    >>> a == b
    False
    

If you don't want to check for another kind of equivalence, you must specify
more in detail what you mean with equivalent.

