根据数字缩放图像的宽度和高度

时间:2018-08-30 14:40:43

标签: node.js image-manipulation node-canvas

我有一定数量的正方形,其宽度和高度为40,是否有任何方法可以将它们“完美地”适合用node-canvas生成的图像,而又不会太大或太小?另外,还要使图像尺寸平衡,以使宽度上没有太多的正方形或高度上没有太多的正方形。

这是我尝试过的:

let b = ((accent.length + other.length + 1) * 40); // the amount of squares * 40 (width/height)
let canvas = new Canvas(b, b);

和:

let b = ((accent.length + other.length + 1) * 40) / 2; // the amount of squares * 40 (width/height)
let canvas = new Canvas(b, b);

但这只会使图像太大或太小。

0 个答案:

没有答案
相关问题