File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
3
3
import pytest
4
- from PIL import Image
5
- from gradio . processing_utils import encode_pil_to_base64
4
+ import base64
5
+
6
6
7
7
test_files_path = os .path .dirname (__file__ ) + "/test_files"
8
8
9
9
10
+ def file_to_base64 (filename ):
11
+ with open (filename , "rb" ) as file :
12
+ data = file .read ()
13
+
14
+ base64_str = str (base64 .b64encode (data ), "utf-8" )
15
+ return "data:image/png;base64," + base64_str
16
+
17
+
10
18
@pytest .fixture (scope = "session" ) # session so we don't read this over and over
11
19
def img2img_basic_image_base64 () -> str :
12
- return encode_pil_to_base64 ( Image . open ( os .path .join (test_files_path , "img2img_basic.png" ) ))
20
+ return file_to_base64 ( os .path .join (test_files_path , "img2img_basic.png" ))
13
21
14
22
15
23
@pytest .fixture (scope = "session" ) # session so we don't read this over and over
16
24
def mask_basic_image_base64 () -> str :
17
- return encode_pil_to_base64 ( Image . open ( os .path .join (test_files_path , "mask_basic.png" ) ))
25
+ return file_to_base64 ( os .path .join (test_files_path , "mask_basic.png" ))
You can’t perform that action at this time.
0 commit comments