155elkhorn commited on
Commit
a8cd4e6
·
1 Parent(s): 59052cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -23,11 +23,22 @@ def crop_image(image, crop_top_percentage, crop_bottom_percentage):
23
 
24
  return cropped_image
25
 
 
 
 
 
26
  def resize_and_overlay_image(input_image, reduction_percentage, shift_percentage_lr, shift_percentage_ud, background_color, crop_top_percentage, crop_bottom_percentage):
27
  # Check if the input image is empty
28
  if input_image.size == 0:
29
  return None
30
 
 
 
 
 
 
 
 
31
  img = np.array(input_image)
32
 
33
  # Check if the image has shape information
 
23
 
24
  return cropped_image
25
 
26
+ def convert_to_jpg(input_image, output_path):
27
+ avif_image = Image.fromarray(input_image)
28
+ avif_image.convert('RGB').sav(output_path, 'JPEG')
29
+
30
  def resize_and_overlay_image(input_image, reduction_percentage, shift_percentage_lr, shift_percentage_ud, background_color, crop_top_percentage, crop_bottom_percentage):
31
  # Check if the input image is empty
32
  if input_image.size == 0:
33
  return None
34
 
35
+ if input_format == 'AVIF' and output_format == 'JPEG':
36
+ # Convert AVIF to JPEG
37
+ temp_jpg_path = "temp_image.jpg"
38
+ convert_to_jpg(input_image, temp_jpg_path)
39
+ input_image = cv2.imread(temp_jpg_path)
40
+ os.remove(temp_jpg_path)
41
+
42
  img = np.array(input_image)
43
 
44
  # Check if the image has shape information