mylesai commited on
Commit
3faa472
·
verified ·
1 Parent(s): c529986

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -11,6 +11,7 @@ from zipfile import ZipFile
11
  import gradio as gr
12
  from docx import Document
13
  from io import BytesIO
 
14
 
15
  # FUNCTIONS
16
 
@@ -78,6 +79,17 @@ def get_seo_tags(image_path, topical_map, attempts=0):
78
  def encode_image(image_path):
79
  # Check the file extension to determine if it is a HEIC file
80
  if image_path.lower().endswith('.heic'):
 
 
 
 
 
 
 
 
 
 
 
81
  # Load the HEIC image
82
  image = Image.open(image_path)
83
  # Convert the image to JPEG format in memory
 
11
  import gradio as gr
12
  from docx import Document
13
  from io import BytesIO
14
+ import pyheif
15
 
16
  # FUNCTIONS
17
 
 
79
  def encode_image(image_path):
80
  # Check the file extension to determine if it is a HEIC file
81
  if image_path.lower().endswith('.heic'):
82
+ # Read the HEIC file
83
+ heif_file = pyheif.read(image_path)
84
+ # Convert to a PIL image
85
+ image = Image.frombytes(
86
+ heif_file.mode,
87
+ heif_file.size,
88
+ heif_file.data,
89
+ "raw",
90
+ heif_file.mode,
91
+ heif_file.stride,
92
+ )
93
  # Load the HEIC image
94
  image = Image.open(image_path)
95
  # Convert the image to JPEG format in memory