'Get the image type.'

def check_kind(self, kind, transform=None):

    if (kind is None):
        kind = self.kind
    allowed = ((not self.allowed_kinds) or (kind in self.allowed_kinds))
    if transform:
        kind = transform(kind)
        if (not allowed):
            allowed = (kind in self.allowed_kinds)
    if (not allowed):
        raise ValueError(('Cannot    set    %s    type    to    %s' % (type(self).__name__, kind)))
    return kind
