Converts image string to numpy array.
(image_string)
| 14 | |
| 15 | |
| 16 | def decode_image_string(image_string): |
| 17 | """ |
| 18 | Converts image string to numpy array. |
| 19 | """ |
| 20 | if "png" in image_string[:22]: |
| 21 | return np.asarray(Image.open(BytesIO(base64.b64decode(image_string[22:])))) |
| 22 | elif "jpeg" in image_string[:23]: |
| 23 | return np.asarray(Image.open(BytesIO(base64.b64decode(image_string[23:])))) |
| 24 | else: |
| 25 | raise ValueError("image string format not recognized") |
| 26 | |
| 27 | |
| 28 | @pytest.mark.parametrize("binary_string", [False, True]) |
no test coverage detected