'Returns a list of colors used in this image.
:param maxcolors: Maximum number of colors.  If this number is
exceeded, this method returns None.  The default limit is
256 colors.
:returns: An unsorted list of (count, pixel) values.'

def getcolors(self, maxcolors=256):

    self.load()
    if (self.mode in ('1', 'L', 'P')):
        h = self.im.histogram()
        out = []
        for i in range(256):
            if h[i]:
                out.append((h[i], i))
        if (len(out) > maxcolors):
            return None
        return out
    return self.im.getcolors(maxcolors)
