``PIL.Image.mode`` equivalent for this image

def mode(self):
        """``PIL.Image.mode`` equivalent for this image"""
        m = ''
        if self.indexed:
            m = 'P'
        elif self.bits_per_component == 1:
            m = '1'
        elif self.bits_per_component == 8:
            if self.colorspace == '/DeviceRGB':
                m = 'RGB'
            elif self.colorspace == '/DeviceGray':
                m = 'L'
            elif self.colorspace == '/DeviceCMYK':
                m = 'CMYK'
        if m == '':
            raise NotImplementedError("Not sure how to handle PDF image of this type")
        return m