Lakpriya Seneviratna commited on
Commit
92a7a68
·
1 Parent(s): 7c563a2

chore: Fix file path case sensitivity issue in load_logo function

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -175,8 +175,7 @@ def create_video_from_title(title, sentences, background_image, output_filename,
175
 
176
  # Logo images
177
  top_logo = load_logo('G.png', frame_width, frame_height, 'top')
178
- bottom_logo = load_logo('follow.png', frame_width, frame_height, 'bottom')
179
-
180
  # Resize the background image
181
  background = resize_background_image(background_image, frame_width, frame_height)
182
 
@@ -318,20 +317,21 @@ def combine_audio_video(video_file, audio_file, output_file, audio_delay_seconds
318
  print("Successfully made the video:", output_file)
319
 
320
  def load_logo(logo_path, frame_width, frame_height, position='top'):
321
- logo = cv2.imread(logo_path, cv2.IMREAD_UNCHANGED) # Load with alpha channel
 
 
 
 
 
 
 
322
  logo_height, logo_width = logo.shape[:2]
323
-
324
- # Scaling down the logo if it's too big
325
  scale_factor = min(1, frame_width / 3 / logo_width, frame_height / 10 / logo_height)
326
- new_size = (int(logo_width * scale_factor*1.3), int(logo_height * scale_factor*1.3))
327
  logo = cv2.resize(logo, new_size, interpolation=cv2.INTER_AREA)
328
 
329
- # Positioning
330
  x_center = frame_width // 2 - logo.shape[1] // 2
331
- if position == 'top':
332
- y_pos = 100 # 10 pixels from the top
333
- else: # 'bottom'
334
- y_pos = frame_height - logo.shape[0] - 100 # 10 pixels from the bottom
335
 
336
  return logo, (x_center, y_pos)
337
 
 
175
 
176
  # Logo images
177
  top_logo = load_logo('G.png', frame_width, frame_height, 'top')
178
+ bottom_logo = load_logo('Follow.png', frame_width, frame_height, 'bottom')
 
179
  # Resize the background image
180
  background = resize_background_image(background_image, frame_width, frame_height)
181
 
 
317
  print("Successfully made the video:", output_file)
318
 
319
  def load_logo(logo_path, frame_width, frame_height, position='top'):
320
+ if not os.path.exists(logo_path):
321
+ raise FileNotFoundError(f"Logo file not found: {logo_path}")
322
+
323
+ logo = cv2.imread(logo_path, cv2.IMREAD_UNCHANGED)
324
+
325
+ if logo is None:
326
+ raise ValueError(f"Failed to load image at path: {logo_path}")
327
+
328
  logo_height, logo_width = logo.shape[:2]
 
 
329
  scale_factor = min(1, frame_width / 3 / logo_width, frame_height / 10 / logo_height)
330
+ new_size = (int(logo_width * scale_factor * 1.3), int(logo_height * scale_factor * 1.3))
331
  logo = cv2.resize(logo, new_size, interpolation=cv2.INTER_AREA)
332
 
 
333
  x_center = frame_width // 2 - logo.shape[1] // 2
334
+ y_pos = 100 if position == 'top' else frame_height - logo.shape[0] - 100
 
 
 
335
 
336
  return logo, (x_center, y_pos)
337