Spaces:
Sleeping
Sleeping
Richard Young
Claude
commited on
Commit
Β·
19f4734
1
Parent(s):
d31350b
Fix image download format - ensure PNG instead of WebP
Browse files- Return file path instead of PIL Image object
- Configure gr.Image with format='png' and type='filepath'
- Ensures steganography data is preserved in lossless PNG
- Prevents Gradio from converting to lossy WebP format
π€ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
app.py
CHANGED
|
@@ -75,9 +75,6 @@ def hide_data_in_image(image, secret_text, password, bits_per_channel):
|
|
| 75 |
os.unlink(output_path)
|
| 76 |
return None, f"β **Error:** {message}"
|
| 77 |
|
| 78 |
-
# Load result image
|
| 79 |
-
result_img = Image.open(output_path)
|
| 80 |
-
|
| 81 |
# Format success message
|
| 82 |
result_message = f"""
|
| 83 |
β
**Successfully Hidden!**
|
|
@@ -97,7 +94,9 @@ def hide_data_in_image(image, secret_text, password, bits_per_channel):
|
|
| 97 |
- Keep your password safe if you used encryption
|
| 98 |
"""
|
| 99 |
|
| 100 |
-
|
|
|
|
|
|
|
| 101 |
|
| 102 |
except Exception as e:
|
| 103 |
if 'input_path' in locals() and os.path.exists(input_path):
|
|
@@ -384,7 +383,7 @@ The image will look identical to the naked eye, but contains your secret message
|
|
| 384 |
hide_button = gr.Button("π Hide Data in Image", variant="primary", size="lg")
|
| 385 |
|
| 386 |
with gr.Column(scale=1):
|
| 387 |
-
hide_output_image = gr.Image(label="Result Image (Download This!)", height=300)
|
| 388 |
hide_output_text = gr.Markdown(label="Status")
|
| 389 |
|
| 390 |
hide_button.click(
|
|
|
|
| 75 |
os.unlink(output_path)
|
| 76 |
return None, f"β **Error:** {message}"
|
| 77 |
|
|
|
|
|
|
|
|
|
|
| 78 |
# Format success message
|
| 79 |
result_message = f"""
|
| 80 |
β
**Successfully Hidden!**
|
|
|
|
| 94 |
- Keep your password safe if you used encryption
|
| 95 |
"""
|
| 96 |
|
| 97 |
+
# Return the file path directly so Gradio serves the PNG file
|
| 98 |
+
# Don't delete output_path - Gradio needs it
|
| 99 |
+
return output_path, result_message
|
| 100 |
|
| 101 |
except Exception as e:
|
| 102 |
if 'input_path' in locals() and os.path.exists(input_path):
|
|
|
|
| 383 |
hide_button = gr.Button("π Hide Data in Image", variant="primary", size="lg")
|
| 384 |
|
| 385 |
with gr.Column(scale=1):
|
| 386 |
+
hide_output_image = gr.Image(label="Result Image (Download This!)", height=300, format="png", type="filepath")
|
| 387 |
hide_output_text = gr.Markdown(label="Status")
|
| 388 |
|
| 389 |
hide_button.click(
|