我正在使用 Graphics Magick 调整图像大小,然后使用循环对该图像进行多次裁剪。裁剪命令第二次运行时,它失败了:Command failed: gm convert: geometry does not contain image (unable to crop image).
这是我的循环代码:
var resizedImage = gm(pathToTemporaryImage).resize(maxSize, maxSize);
resizedImage.size(function(error, size) {
for (var x = 0; x < size.width; x += kGridSize) {
for (var y = 0; y < size.height; y += kGridSize) {
// Calculate the grid element width and height
var width = Math.min(kGridSize, size.width - x);
var height = Math.min(kGridSize, size.height - y);
resizedImage.page(0, 0, '+0+0')
.crop(width, height, x, y)
.quality(Math.min(frameTick.quality, 100))
.write(pathToImage + '-' + x + '-' + y + '.jpg', callback(x, y));
}
}
}