mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Check for user avatar crop
This commit is contained in:
@ -915,7 +915,7 @@ async function tryReadImage(img_url, crop) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function charaRead(img_url, input_format) {
|
async function charaRead(img_url, input_format) {
|
||||||
return characterCardParser.parse(img_url, input_format);
|
return characterCardParser.parse(img_url, input_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.post("/getcharacters", jsonParser, function (request, response) {
|
app.post("/getcharacters", jsonParser, function (request, response) {
|
||||||
@ -1873,7 +1873,7 @@ app.post('/uploaduseravatar', urlencodedParser, async (request, response) => {
|
|||||||
const crop = tryParse(request.query.crop);
|
const crop = tryParse(request.query.crop);
|
||||||
let rawImg = await jimp.read(pathToUpload);
|
let rawImg = await jimp.read(pathToUpload);
|
||||||
|
|
||||||
if (typeof crop == 'object') {
|
if (typeof crop == 'object' && [crop.x, crop.y, crop.width, crop.height].every(x => typeof x === 'number')) {
|
||||||
rawImg = rawImg.crop(crop.x, crop.y, crop.width, crop.height);
|
rawImg = rawImg.crop(crop.x, crop.y, crop.width, crop.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user