fix error when no generated image response

This commit is contained in:
Carl Zhang
2025-10-03 21:42:53 -05:00
parent 0375584d53
commit c4066ed15e

View File

@@ -75,14 +75,14 @@ def ai_image_editor():
st.info(text_response)
if image_response:
st.image(image_response, width=300)
# Convert PIL image to bytes for download
img_byte_arr = BytesIO()
image_response.save(img_byte_arr, format="JPEG")
st.download_button(
label="Download Edited Image",
data=img_byte_arr.getvalue(),
file_name="edited_image.jpeg",
mime="image/jpeg"
)
# Convert PIL image to bytes for download
img_byte_arr = BytesIO()
image_response.save(img_byte_arr, format="JPEG")
st.download_button(
label="Download Edited Image",
data=img_byte_arr.getvalue(),
file_name="edited_image.jpeg",
mime="image/jpeg"
)