API return small land image
parent
c14b220179
commit
ced2036862
@ -0,0 +1,21 @@
|
|||||||
|
import Jimp from 'jimp'
|
||||||
|
|
||||||
|
export default async function handler(req, res) {
|
||||||
|
const img = req.query.img
|
||||||
|
const baseURL = "https://orthoverse.io/api/img/"
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
console.log(baseURL + img)
|
||||||
|
Jimp.read(baseURL + img).then((image) => {
|
||||||
|
image.resize(166,166).getBuffer(Jimp.MIME_PNG, (err, buffer) => {
|
||||||
|
res.status(200).write(buffer)
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err)
|
||||||
|
res.status(404).json({ error: "Not found" })
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue