Beispiel #1
0
    def pattern_open(self, image):
        if self.__screensize is None:
            self.__screensize = self.display

        if isinstance(image, Pattern):
            if image._image is None:
                image_path = self._search_image(image._name)
                image._image = imutils.open(image_path)
            return image

        if isinstance(image, basestring):
            image_path = base.lookup_image(image, self.__screensize[0],
                                           self.__screensize[1])
            if image_path is None:
                raise IOError('file not found: {}'.format(image))
            return Pattern(image_path, image=imutils.open(image_path))

        if 'numpy' in str(type(image)):
            return Pattern('unknown', image=image)

        raise TypeError("Not supported image type: {}".format(type(image)))
Beispiel #2
0
 def _open_image_file(self, path):
     realpath = base.lookup_image(path, self.__screensize[0], self.__screensize[1])
     if realpath is None:
         raise IOError('file not found: {}'.format(path))
     return imutils.open(realpath)