Beispiel #1
0
 def call_fixture(self, request):
     image_filename, expected_class = request.param
     image_path = test_file(image_filename)
     with open(image_path, 'rb') as f:
         blob = f.read()
     image_stream = BytesIO(blob)
     image_stream.seek(666)
     return image_stream, expected_class
Beispiel #2
0
 def call_fixture(self, request):
     image_filename, expected_class = request.param
     image_path = test_file(image_filename)
     with open(image_path, 'rb') as f:
         blob = f.read()
     image_stream = BytesIO(blob)
     image_stream.seek(666)
     return image_stream, expected_class
Beispiel #3
0
 def from_file(cls, image_descriptor):
     """
     Return a new |Image| instance loaded from the image file identified
     by *image_descriptor*, a path or file-like object.
     """
     if is_string(image_descriptor):
         path = image_descriptor
         with open(path, 'rb') as f:
             blob = f.read()
             stream = BytesIO(blob)
         filename = os.path.basename(path)
     else:
         stream = image_descriptor
         stream.seek(0)
         blob = stream.read()
         filename = None
     return cls._from_stream(stream, blob, filename)