artintel235 commited on
Commit
dd20192
·
verified ·
1 Parent(s): 2f22314

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -349,37 +349,37 @@ def main_app():
349
  image_result = generate_image(prompt, aspect_ratio, realism)
350
  if isinstance(image_result, tuple) and len(image_result) == 2 and image_result[0] is not None:
351
  image, image_url = image_result
352
-
353
  # Define the boundary size
354
  preview_size = 400
355
-
356
  # Get original image dimensions
357
  original_width, original_height = image.size
358
-
359
  # Calculate scaling factor to fit within the boundary
360
  width_ratio = preview_size / original_width
361
  height_ratio = preview_size / original_height
362
-
363
  scaling_factor = min(width_ratio, height_ratio)
364
-
365
  # Calculate new dimensions
366
  new_width = int(original_width * scaling_factor)
367
  new_height = int(original_height * scaling_factor)
368
-
369
  # Resize the image
370
  resized_image = image.resize((new_width, new_height), Image.LANCZOS)
371
-
372
  # Upload the high-resolution image
373
  cloud_storage_url = upload_image_to_storage(image, st.session_state.current_user, is_thumbnail=False)
374
-
375
  if cloud_storage_url:
376
  # Create thumbnail from the high-resolution image
377
  thumbnail = create_thumbnail(image)
378
-
379
  if thumbnail:
380
  # Upload thumbnail to cloud storage and store url
381
  thumbnail_url = upload_image_to_storage(thumbnail, st.session_state.current_user, is_thumbnail=True)
382
-
383
  if thumbnail_url:
384
  # Store image data in database
385
  store_image_data_in_db(st.session_state.current_user, prompt, aspect_ratio, realism, cloud_storage_url, thumbnail_url)
@@ -398,7 +398,7 @@ def main_app():
398
  st.error("Failed to create thumbnail")
399
  else:
400
  st.error("Failed to upload image to cloud storage.")
401
-
402
  else:
403
  st.error(f"Image generation failed: {image_result}")
404
  else:
 
349
  image_result = generate_image(prompt, aspect_ratio, realism)
350
  if isinstance(image_result, tuple) and len(image_result) == 2 and image_result[0] is not None:
351
  image, image_url = image_result
352
+
353
  # Define the boundary size
354
  preview_size = 400
355
+
356
  # Get original image dimensions
357
  original_width, original_height = image.size
358
+
359
  # Calculate scaling factor to fit within the boundary
360
  width_ratio = preview_size / original_width
361
  height_ratio = preview_size / original_height
362
+
363
  scaling_factor = min(width_ratio, height_ratio)
364
+
365
  # Calculate new dimensions
366
  new_width = int(original_width * scaling_factor)
367
  new_height = int(original_height * scaling_factor)
368
+
369
  # Resize the image
370
  resized_image = image.resize((new_width, new_height), Image.LANCZOS)
371
+
372
  # Upload the high-resolution image
373
  cloud_storage_url = upload_image_to_storage(image, st.session_state.current_user, is_thumbnail=False)
374
+
375
  if cloud_storage_url:
376
  # Create thumbnail from the high-resolution image
377
  thumbnail = create_thumbnail(image)
378
+
379
  if thumbnail:
380
  # Upload thumbnail to cloud storage and store url
381
  thumbnail_url = upload_image_to_storage(thumbnail, st.session_state.current_user, is_thumbnail=True)
382
+
383
  if thumbnail_url:
384
  # Store image data in database
385
  store_image_data_in_db(st.session_state.current_user, prompt, aspect_ratio, realism, cloud_storage_url, thumbnail_url)
 
398
  st.error("Failed to create thumbnail")
399
  else:
400
  st.error("Failed to upload image to cloud storage.")
401
+
402
  else:
403
  st.error(f"Image generation failed: {image_result}")
404
  else: