Get big thumbnails now

This commit is contained in:
Brett Williams
2023-05-31 23:11:37 -05:00
parent f039bfae35
commit 8c19a50d60
2 changed files with 29 additions and 4 deletions

View File

@@ -44,8 +44,23 @@ class ZordonClient:
self.job_cache = []
# Setup photo preview
self.photo_label = tk.Label(self.root, width=400, height=300)
self.photo_label.pack()
photo_pad = tk.Frame(self.root, background="gray")
photo_pad.pack(fill=tk.BOTH, pady=5, padx=5)
self.photo_label = tk.Label(photo_pad, height=500)
self.photo_label.pack(fill=tk.BOTH, expand=True)
server_frame = tk.LabelFrame(self.root, text="Server")
server_frame.pack(fill=tk.X, pady=5, padx=5, expand=True)
server_picker_frame = tk.Frame(server_frame)
server_picker_frame.pack(fill=tk.X, expand=True)
server_label = tk.Label(server_picker_frame, text="Current Server:")
server_label.pack(side=tk.LEFT, padx=5)
self.server_combo = tk.ttk.Combobox(server_picker_frame)
self.server_combo.pack(fill=tk.X)
self.server_combo.bind("<<ComboboxSelected>>", self.server_picked)
self.server_combo['values'] = servers
self.server_combo.current(0)
# Setup the Tree
self.tree = ttk.Treeview(self.root, show="headings")
@@ -87,7 +102,7 @@ class ZordonClient:
# Start the Tkinter event loop
self.root.geometry("500x600+300+300")
self.root.maxsize(width=2000, height=1200)
self.root.minsize(width=600, height=600)
self.root.minsize(width=900, height=1000)
make_sortable(self.tree)
self.update_jobs()
@@ -113,7 +128,7 @@ class ZordonClient:
job_id = row_data['values'][0]
# update thumb
thumb_url = f'http://{self.server_proxy.hostname}:{self.server_proxy.port}/ui/job/{job_id}/thumbnail'
thumb_url = f'http://{self.server_proxy.hostname}:{self.server_proxy.port}/ui/job/{job_id}/thumbnail?size=big'
response = requests.get(thumb_url)
if response.status_code == 200:
try:

View File

@@ -70,17 +70,27 @@ def job_detail(job_id):
@server.route('/ui/job/<job_id>/thumbnail')
def job_thumbnail(job_id):
big_thumb = request.args.get('size', False) == "big"
found_job = RenderQueue.job_with_id(job_id, none_ok=True)
if found_job:
os.makedirs(server.config['THUMBS_FOLDER'], exist_ok=True)
thumb_video_path = os.path.join(server.config['THUMBS_FOLDER'], found_job.id + '.mp4')
thumb_image_path = os.path.join(server.config['THUMBS_FOLDER'], found_job.id + '.jpg')
big_video_path = os.path.join(server.config['THUMBS_FOLDER'], found_job.id + '_big.mp4')
big_image_path = os.path.join(server.config['THUMBS_FOLDER'], found_job.id + '_big.jpg')
if not os.path.exists(thumb_video_path) and not os.path.exists(thumb_video_path + '_IN-PROGRESS') and \
found_job.status not in [RenderStatus.CANCELLED, RenderStatus.ERROR]:
generate_thumbnail_for_job(found_job, thumb_video_path, thumb_image_path, max_width=240)
if big_thumb and os.path.exists(big_video_path) and not os.path.exists(big_video_path + '_IN-PROGRESS'):
return send_file(big_video_path, mimetype="video/mp4")
elif big_thumb and os.path.exists(big_image_path):
return send_file(big_image_path, mimetype='image/jpeg')
elif not os.path.exists(big_video_path) and not os.path.exists(big_image_path + '_IN-PROGRESS') and \
found_job.status not in [RenderStatus.CANCELLED, RenderStatus.ERROR]:
generate_thumbnail_for_job(found_job, big_video_path, big_image_path, max_width=800)
if os.path.exists(thumb_video_path) and not os.path.exists(thumb_video_path + '_IN-PROGRESS'):
return send_file(thumb_video_path, mimetype="video/mp4")
elif os.path.exists(thumb_image_path):