| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/@nuxtjs/pwa/lib/ |
Upload File : |
const path = require('path')
const jimp = require('jimp-compact')
async function resize ({ input, distDir, sizes }) {
const inputFile = await jimp.read(input)
// Icons
await Promise.all(sizes.map(normalizeSize).map((size) => {
const name = sizeName(size)
const distFile = path.join(distDir, `${name}.png`)
return new Promise((resolve) => {
inputFile.clone().contain(size[0], size[1]).write(distFile, () => resolve())
})
}))
}
resize(JSON.parse(process.argv[2])).then(() => {
process.exit(0)
}).catch((error) => {
console.error(error) // eslint-disable-line no-console
process.exit(1)
})
// TODO: Dedup
function sizeName (size) {
size = normalizeSize(size)
const prefix = size[2] ? (size[2] + '_') : ''
return prefix + size[0] + 'x' + size[1]
}
// TODO: Dedup
function normalizeSize (size) {
if (!Array.isArray(size)) {
size = [size, size]
}
if (size.length === 1) {
size = [size, size]
} else if (size.length === 0) {
size = 64
}
return size
}