updated to 4k images from pptx
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -130,7 +130,7 @@ def add_player(username, hostname, password, quickconnect_password, orientation=
|
||||
log_player_created(username, hostname)
|
||||
return new_player
|
||||
|
||||
def edit_player(player_id, username, hostname, password=None, quickconnect_password=None):
|
||||
def edit_player(player_id, username, hostname, password=None, quickconnect_password=None, orientation=None):
|
||||
"""
|
||||
Edit an existing player's details.
|
||||
"""
|
||||
@@ -147,6 +147,9 @@ def edit_player(player_id, username, hostname, password=None, quickconnect_passw
|
||||
if quickconnect_password:
|
||||
player.quickconnect_password = bcrypt.generate_password_hash(quickconnect_password).decode('utf-8')
|
||||
|
||||
if orientation:
|
||||
player.orientation = orientation
|
||||
|
||||
db.session.commit()
|
||||
log_player_edited(username)
|
||||
return player
|
||||
|
||||
@@ -105,23 +105,14 @@ def convert_video_and_update_playlist(app, file_path, original_filename, target_
|
||||
print(f"Video conversion failed for: {file_path}")
|
||||
|
||||
# PDF conversion functions
|
||||
def convert_pdf_to_images(pdf_file, output_folder, delete_pdf=True):
|
||||
def convert_pdf_to_images(pdf_file, output_folder, delete_pdf=True, dpi=600):
|
||||
"""
|
||||
Convert a PDF file to images in sequential order.
|
||||
|
||||
Args:
|
||||
pdf_file (str): Path to the PDF file
|
||||
output_folder (str): Path to save the images
|
||||
delete_pdf (bool): Whether to delete the PDF file after processing
|
||||
|
||||
Returns:
|
||||
list: List of generated image filenames in page order, or empty list if conversion failed
|
||||
Convert a PDF file to images in sequential order at high resolution (4K).
|
||||
"""
|
||||
print(f"Converting PDF to images: {pdf_file}")
|
||||
print(f"Converting PDF to images: {pdf_file} at {dpi} DPI")
|
||||
try:
|
||||
# Convert PDF to images
|
||||
images = convert_from_path(pdf_file, dpi=300)
|
||||
print(f"Number of pages in PDF: {len(images)}")
|
||||
images = convert_from_path(pdf_file, dpi=dpi)
|
||||
base_name = os.path.splitext(os.path.basename(pdf_file))[0]
|
||||
image_filenames = []
|
||||
|
||||
@@ -240,6 +231,7 @@ def process_pptx(input_file, output_folder, duration, target_type, target_id):
|
||||
'--headless',
|
||||
'--convert-to', 'pdf',
|
||||
'--outdir', output_folder,
|
||||
'--printer-resolution', '600',
|
||||
input_file
|
||||
]
|
||||
|
||||
@@ -251,7 +243,7 @@ def process_pptx(input_file, output_folder, duration, target_type, target_id):
|
||||
print(f"LibreOffice errors (if any): {result.stderr.decode()}")
|
||||
|
||||
# Step 2: Convert PDF to images and update playlist
|
||||
image_filenames = convert_pdf_to_images(pdf_file, output_folder, True)
|
||||
image_filenames = convert_pdf_to_images(pdf_file, output_folder, True, dpi=600)
|
||||
|
||||
# Verify we got images
|
||||
if not image_filenames:
|
||||
@@ -306,7 +298,7 @@ def process_uploaded_files(app, files, media_type, duration, target_type, target
|
||||
if media_type == 'image':
|
||||
add_image_to_playlist(app, file, filename, duration, target_type, target_id)
|
||||
result['message'] = f"Image {filename} added to playlist"
|
||||
log_upload('image', filename, target_type, target_name)
|
||||
log_upload('image', filename, target_type, target_id)
|
||||
|
||||
elif media_type == 'video':
|
||||
# For videos, add to playlist then start conversion in background
|
||||
@@ -329,7 +321,7 @@ def process_uploaded_files(app, files, media_type, duration, target_type, target
|
||||
threading.Thread(target=convert_video_and_update_playlist,
|
||||
args=(app, file_path, filename, target_type, target_id, duration)).start()
|
||||
result['message'] = f"Video {filename} added to playlist and being processed"
|
||||
log_upload('video', filename, target_type, target_name)
|
||||
log_upload('video', filename, target_type, target_id)
|
||||
|
||||
elif media_type == 'pdf':
|
||||
# For PDFs, convert to images and update playlist
|
||||
@@ -337,7 +329,7 @@ def process_uploaded_files(app, files, media_type, duration, target_type, target
|
||||
duration, target_type, target_id)
|
||||
if success:
|
||||
result['message'] = f"PDF {filename} processed successfully"
|
||||
log_process('pdf', filename, target_type, target_name)
|
||||
log_process('pdf', filename, target_type, target_id)
|
||||
else:
|
||||
result['success'] = False
|
||||
result['message'] = f"Error processing PDF file: {filename}"
|
||||
@@ -348,7 +340,7 @@ def process_uploaded_files(app, files, media_type, duration, target_type, target
|
||||
duration, target_type, target_id)
|
||||
if success:
|
||||
result['message'] = f"PowerPoint {filename} processed successfully"
|
||||
log_process('ppt', filename, target_type, target_name)
|
||||
log_process('ppt', filename, target_type, target_id)
|
||||
else:
|
||||
result['success'] = False
|
||||
result['message'] = f"Error processing PowerPoint file: {filename}"
|
||||
|
||||
Reference in New Issue
Block a user