mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Test allowing any image to be used in meme commands
This commit is contained in:
@@ -146,4 +146,21 @@ module.exports = class CanvasUtil {
|
||||
}
|
||||
return { x, y, width, height };
|
||||
}
|
||||
|
||||
static centerImagePart(data, maxWidth, maxHeight, widthOffset, heightOffest) {
|
||||
let { width, height } = data;
|
||||
if (width > maxWidth) {
|
||||
const ratio = maxWidth / width;
|
||||
width = maxWidth;
|
||||
height *= ratio;
|
||||
}
|
||||
if (height > maxHeight) {
|
||||
const ratio = maxHeight / height;
|
||||
height = maxHeight;
|
||||
width *= ratio;
|
||||
}
|
||||
const x = widthOffset + ((maxWidth / 2) - (width / 2));
|
||||
const y = heightOffest + ((maxHeight / 2) - (height / 2));
|
||||
return { x, y, width, height };
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user