You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
601 B
JavaScript
26 lines
601 B
JavaScript
import Jimp from 'jimp'
|
|
import { useRouter } from "next/router"
|
|
|
|
export default async function handler(req, res) {
|
|
const img = req.query.img
|
|
const baseURL = "https://orthoverse.io/api/img/"
|
|
|
|
try {
|
|
const image = await Jimp.read(baseURL + img)
|
|
image
|
|
.crop(4,168,412,190)
|
|
.resize(316,144)
|
|
.getBuffer(Jimp.MIME_PNG, (err, buffer) => {
|
|
res.statusCode = 200
|
|
res.setHeader("Content-Type", "image/png");
|
|
res.write(buffer)
|
|
res.end()
|
|
})
|
|
} catch (err) {
|
|
console.log(err)
|
|
res.status(404)
|
|
res.json({ error: "Not found" })
|
|
res.end()
|
|
}
|
|
}
|