图像缩小使用织物js调整大小

时间:2017-02-28 18:06:16

标签: javascript fabricjs

我正在使用fabric js。编辑并保存图像后,它在画布上缩小并且质量下降。

这是在保存和通过ajax调用发送时使用的代码。

c.discardActiveGroup().renderAll();

var objs = c.getObjects().map(function(o) {
    return o.set({'active': false, hasBorders: false});
});

var group = new fabric.Group(objs, {
    originX: 'center', 
    originY: 'center',
    strokeWidth : 0
});

var cloneGroup = new fabric.Group(objs, {
    originX: 'center', 
    originY: 'center',
    strokeWidth : 0
});

cloneGroup.scaleToWidth(imgWidth-1);

var dataURL = cloneGroup.toDataURL({
    format: 'png',
    left: 1,
    top: 1,
    width: imgWidth,
    height: imgHeight
});

saveAjaxCall(dataURL, flagBit);

group._restoreObjectsState();

c.remove(cloneGroup);

c.renderAll();

0 个答案:

没有答案