Spaces:
Sleeping
Sleeping
Update src/utils/functions.py
Browse files- src/utils/functions.py +6 -4
src/utils/functions.py
CHANGED
|
@@ -22,12 +22,14 @@ def convertImageToBase64(image: Image.Image) -> str:
|
|
| 22 |
Args:
|
| 23 |
image: image object
|
| 24 |
Returns:
|
| 25 |
-
imageString: base64
|
| 26 |
"""
|
| 27 |
buffered = BytesIO()
|
| 28 |
-
image.save(buffered, format
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
|
| 32 |
def getYaml(yamlFilePath: str) -> dict:
|
| 33 |
"""
|
|
|
|
| 22 |
Args:
|
| 23 |
image: image object
|
| 24 |
Returns:
|
| 25 |
+
imageString: base64 uri of the image
|
| 26 |
"""
|
| 27 |
buffered = BytesIO()
|
| 28 |
+
image.save(buffered, format="JPEG", optimize=True, quality=85)
|
| 29 |
+
imageBytes = buffered.getvalue()
|
| 30 |
+
imageBase64 = base64.b64encode(imageBytes).decode("utf-8")
|
| 31 |
+
dataUri = f"data:image/jpeg;base64,{imageBase64}"
|
| 32 |
+
return dataUri
|
| 33 |
|
| 34 |
def getYaml(yamlFilePath: str) -> dict:
|
| 35 |
"""
|