Exemple #1
0
 def test_image_initialize(self):
     path = Path(ONE_FACE)
     with path.open("rb") as file:
         binaryBody = file.read()
     img = Image.open(ONE_FACE)
     npBody = np.asarray(img)
     coreBody = fe.Image()
     coreBody.load(ONE_FACE)
     InitCase = namedtuple("InitCase", ("initType", "body"))
     cases = (InitCase("bytes",
                       binaryBody), InitCase("numpy array", npBody),
              InitCase("core", coreBody))
     for case in cases:
         with self.subTest(initType=case.initType):
             image = VLImage(body=case.body, filename=case.initType)
             assert case.initType == image.filename
             assert image.isValid()
             assert image.rect == Rect(0, 0, 912, 1080)
Exemple #2
0
    def test_image_initialize(self):
        """
        Test create VLImage with image body
        """
        binaryBody = Path(ONE_FACE).read_bytes()
        bytearrayBody = bytearray(binaryBody)
        imageWithOneFace = Image.open(ONE_FACE)
        coreBody = fe.Image()
        coreBody.load(ONE_FACE)

        InitCase = namedtuple("InitCase", ("initType", "body"))
        cases = (
            InitCase("bytes", binaryBody),
            InitCase("byte array", bytearrayBody),
            InitCase("core", coreBody),
            InitCase("pillow img", imageWithOneFace),
        )
        for case in cases:
            with self.subTest(initType=case.initType):
                imageVl = VLImage(body=case.body, filename=case.initType)
                assert imageVl.isValid()
                assert case.initType == imageVl.filename
                assert imageVl.rect == Rect(0, 0, 912, 1080)