|
|
@ -7,14 +7,30 @@ export default async function handler(req, res) {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const image = await Jimp.read(baseURL + img)
|
|
|
|
const image = await Jimp.read(baseURL + img)
|
|
|
|
|
|
|
|
const crest = image.clone().crop(3,5,60,96)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const level = parseInt(
|
|
|
|
|
|
|
|
img.substring(
|
|
|
|
|
|
|
|
img.indexOf("-") + 1,
|
|
|
|
|
|
|
|
img.lastIndexOf(".")
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (level % 8 > 0) {
|
|
|
|
|
|
|
|
image
|
|
|
|
|
|
|
|
.composite(crest, 10, 173, {
|
|
|
|
|
|
|
|
mode: Jimp.BLEND_SOURCE_OVER,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
image
|
|
|
|
image
|
|
|
|
.crop(4,168,412,190)
|
|
|
|
.crop(4,168,412,190)
|
|
|
|
.resize(316,143)
|
|
|
|
.resize(316,143)
|
|
|
|
.getBuffer(Jimp.MIME_PNG, (err, buffer) => {
|
|
|
|
.getBuffer(Jimp.MIME_PNG, (err, buffer) => {
|
|
|
|
res.statusCode = 200
|
|
|
|
res.statusCode = 200
|
|
|
|
res.setHeader("Content-Type", "image/png");
|
|
|
|
res.setHeader("Content-Type", "image/png");
|
|
|
|
res.write(buffer)
|
|
|
|
res.write(buffer)
|
|
|
|
res.end()
|
|
|
|
res.end()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
console.log(err)
|
|
|
|
console.log(err)
|
|
|
|