Spaces:
Build error
Build error
update helper
Browse files
helper.py
CHANGED
|
@@ -219,16 +219,16 @@ def save_image(img, flag=""):
|
|
| 219 |
if not os.path.exists(path):
|
| 220 |
os.makedirs(path)
|
| 221 |
if flag:
|
| 222 |
-
flag = "_" + flag
|
| 223 |
# Generate a unique filename
|
| 224 |
unique_name = str(uuid.uuid4()) + flag + ".webp"
|
| 225 |
unique_name = os.path.join(path, unique_name)
|
| 226 |
-
|
| 227 |
# Convert the image to WebP format
|
| 228 |
webp_img = img.convert("RGB") # Ensure the image is in RGB mode
|
| 229 |
|
| 230 |
# Save the image in WebP format with high quality
|
| 231 |
-
webp_img.save(unique_name, "WEBP", quality=
|
| 232 |
|
| 233 |
# Open the saved WebP file and return it as a PIL Image object
|
| 234 |
with Image.open(unique_name) as webp_file:
|
|
|
|
| 219 |
if not os.path.exists(path):
|
| 220 |
os.makedirs(path)
|
| 221 |
if flag:
|
| 222 |
+
flag = "_" + flag
|
| 223 |
# Generate a unique filename
|
| 224 |
unique_name = str(uuid.uuid4()) + flag + ".webp"
|
| 225 |
unique_name = os.path.join(path, unique_name)
|
| 226 |
+
|
| 227 |
# Convert the image to WebP format
|
| 228 |
webp_img = img.convert("RGB") # Ensure the image is in RGB mode
|
| 229 |
|
| 230 |
# Save the image in WebP format with high quality
|
| 231 |
+
webp_img.save(unique_name, "WEBP", quality=100)
|
| 232 |
|
| 233 |
# Open the saved WebP file and return it as a PIL Image object
|
| 234 |
with Image.open(unique_name) as webp_file:
|