Made changes to screenshot handling.

This commit is contained in:
Jakob Friedl
2025-10-14 21:05:36 +02:00
parent 21137f6db5
commit df04eafc13
6 changed files with 32 additions and 15 deletions

View File

@@ -146,15 +146,14 @@ proc sendBuildlogItem*(client: WsConnection, logType: LogType, message: string)
if client != nil:
client.ws.sendEvent(event, client.sessionKey)
proc createThumbnail(data: string, maxWidth: int = 1024, quality: int = 90): string =
proc createThumbnail(data: string, maxHeight: int = 1024, quality: int = 80): string =
let img: Image = decodeImage(data)
let aspectRatio = img.height.float / img.width.float
let
width = min(maxWidth, img.width)
height = int(width.float * aspectRatio)
# Resize image
let aspectRatio = img.width.float / img.height.float
let
height = min(maxHeight, img.height)
width = int(height.float * aspectRatio)
let thumbnail = img.resize(width, height)
# Convert to JPEG image for smaller file size