updated the upload functionality to handle large files and added a new image file
This commit is contained in:
@@ -290,21 +290,33 @@ def process_pptx(input_file, output_folder, duration, target_type, target_id):
|
||||
|
||||
try:
|
||||
# Step 1: Convert PPTX to PDF using LibreOffice for vector quality
|
||||
print("Step 1: Converting PPTX to PDF...")
|
||||
from utils.pptx_converter import pptx_to_pdf_libreoffice
|
||||
pdf_file = pptx_to_pdf_libreoffice(input_file, output_folder)
|
||||
|
||||
if not pdf_file:
|
||||
print("Error: Failed to convert PPTX to PDF")
|
||||
print("This could be due to:")
|
||||
print("- LibreOffice not properly installed")
|
||||
print("- Corrupted PPTX file")
|
||||
print("- Insufficient memory")
|
||||
print("- File permission issues")
|
||||
return False
|
||||
|
||||
print(f"PPTX successfully converted to PDF: {pdf_file}")
|
||||
|
||||
# Step 2: Use the same PDF to images workflow as direct PDF uploads
|
||||
print("Step 2: Converting PDF to JPG images...")
|
||||
# Convert PDF to JPG images (300 DPI, same as PDF workflow)
|
||||
image_filenames = convert_pdf_to_images(pdf_file, output_folder, delete_pdf=True, dpi=300)
|
||||
|
||||
if not image_filenames:
|
||||
print("Error: Failed to convert PDF to images")
|
||||
print("This could be due to:")
|
||||
print("- poppler-utils not properly installed")
|
||||
print("- PDF corruption during conversion")
|
||||
print("- Insufficient disk space")
|
||||
print("- Memory issues during image processing")
|
||||
return False
|
||||
|
||||
print(f"Generated {len(image_filenames)} JPG images from PPTX → PDF")
|
||||
@@ -313,11 +325,14 @@ def process_pptx(input_file, output_folder, duration, target_type, target_id):
|
||||
if os.path.exists(input_file):
|
||||
os.remove(input_file)
|
||||
print(f"Original PPTX file deleted: {input_file}")
|
||||
|
||||
|
||||
# Step 4: Update playlist with generated images in sequential order
|
||||
print("Step 3: Adding images to playlist...")
|
||||
success = update_playlist_with_files(image_filenames, duration, target_type, target_id)
|
||||
if success:
|
||||
print(f"Successfully processed PPTX: {len(image_filenames)} images added to playlist")
|
||||
else:
|
||||
print("Error: Failed to add images to playlist database")
|
||||
return success
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user