| Server IP : 217.154.3.148 / Your IP : 216.73.216.90 Web Server : nginx/1.30.3 System : Linux blissful-wright.217-154-3-148.plesk.page 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : gracious-boyd_hfhh1h8vo9n ( 10000) PHP Version : 8.3.31 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/gracious-boyd.217-154-3-148.plesk.page/nextjs/scripts/ |
Upload File : |
import fs from 'fs'
import sharp from 'sharp'
import { normalizeWithPreset } from '@/lib/mask/normalize'
async function main() {
const worker = JSON.parse(fs.readFileSync('/tmp/worker.json', 'utf-8'))
const maskBuf = Buffer.from(worker.mask, 'base64')
const { data, info } = await sharp(maskBuf).ensureAlpha().removeAlpha().raw().toBuffer({ resolveWithObject: true })
const mask = new Uint8Array(data)
console.log('mask size', info.width, info.height)
let cov = 0
for (let i = 0; i < mask.length; i++) if (mask[i] >= 128) cov++
console.log('cov raw', cov / mask.length)
const gray = new Uint8Array(mask)
const res = normalizeWithPreset({ mask, width: info.width, height: info.height, gray, preset: 'tiles-default' })
let afterCov = 0
for (let i = 0; i < res.result.data.length; i++) if (res.result.data[i]) afterCov++
console.log('after cov', afterCov / res.result.data.length)
console.log(res.result.stats)
}
main().catch(err => { console.error(err); process.exit(1) })