import strutils, system, terminal, tiny_sqlite, pixie import stb_image/write as stbiw import ../core/logger import ../../common/[types, utils] proc dbStoreLoot*(cq: Conquest, loot: LootItem): bool = try: let conquestDb = openDatabase(cq.dbPath, mode=dbReadWrite) conquestDb.exec(""" INSERT INTO loot (lootId, itemType, agentId, host, path, timestamp, size) VALUES (?, ?, ?, ?, ?, ?, ?); """, loot.lootId, int(loot.itemType), loot.agentId, loot.host, loot.path, loot.timestamp, loot.size) conquestDb.close() except: cq.error(getCurrentExceptionMsg()) return false return true proc createThumbnail*(data: string, maxWidth: int = 1024, quality: int = 90): 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 thumbnail = img.resize(width, height) # Convert to JPEG image for smaller file size var rgbaData = newSeq[byte](width * height * 4) var i = 0 for y in 0..