CropperJS在页面上创建新图像,而不是裁剪指定图像

时间:2019-02-23 02:49:28

标签: javascript cropperjs

使用cropper js尝试在页面上裁剪img, 实际上是在页面上附加了2张相同的图片,我可以“滚动”它们来更改其长宽比。

            const cropper = new Cropper(image, {
                aspectRatio: 16 / 9,
                crop(event) {
                    console.log(event.detail.x);
                    console.log(event.detail.y);
                    console.log(event.detail.width);
                    console.log(event.detail.height);
                    console.log(event.detail.rotate);
                    console.log(event.detail.scaleX);
                    console.log(event.detail.scaleY);
                }
});

我也试图这样做以设置作物大小;

       viewMode: 1,
        setData() {
            x: dimensions.left;
            y: dimensions.top;
            width: dimensions.width;
            height: dimensions.height;
        }

但是,事实证明这很困难。我想念什么吗?

1 个答案:

答案 0 :(得分:0)

Switched to using the Jimp library. Was much easier to figure out how to crop using that.