fix: 微调gemini识图,删除本地缓存

This commit is contained in:
ikechan8370 2025-02-03 20:11:25 +08:00
parent f05da98d37
commit bbba9bc872

View file

@ -744,12 +744,9 @@ class Core {
const image = await getImg(e) const image = await getImg(e)
let imageUrl = image ? image[0] : undefined let imageUrl = image ? image[0] : undefined
if (imageUrl) { if (imageUrl) {
let md5 = imageUrl.split(/[/-]/).find(s => s.length === 32)?.toUpperCase() const response = await fetch(imageUrl)
let imageLoc = await getOrDownloadFile(`ocr/${md5}.png`, imageUrl) const base64Image = Buffer.from(await response.arrayBuffer())
let outputLoc = imageLoc.replace(`${md5}.png`, `${md5}_512.png`) option.image = base64Image.toString('base64')
await resizeAndCropImage(imageLoc, outputLoc, 512)
let buffer = fs.readFileSync(outputLoc)
option.image = buffer.toString('base64')
} }
if (opt.enableSmart) { if (opt.enableSmart) {
/** /**