Multiplier property not working properly in “toDataURL” function with cropping in Fabric.js

给你一囗甜甜゛ 提交于 2019-12-12 08:47:15

问题


My original size of the canvas is 800X700.

I am using clipTo to work in a selected portion of a canvas:

var rect = new fabric.Rect({
  left: 100,
  top: 50,
  fill: '#fff',
  width: 376,
  height: 602,
  strokeWidth: 0,
  selectable: false
});

rect.set({
    clipFor: 'mainCanvas',
});

I make sure all the images and text fall within this portion of the canvas.

What I want to Do:

I want to scale up this portion of canvas to a width and height of 1500X2400 so that it can be used for printing

I am using the below toDataURL function with multiplier as 3

var imgData= canvas.toDataURL({
  format: 'png',
  width: 376,
  height: 602,
  top: 50,
  left: 100,
  multiplier: 3
});

But I am getting only top most portion of the image. Any solution?


Update: More info about the problem

I am using Ubuntu 16.04 and Fabric.js-1.6.2

Demonstrating the problem on JsFiddle

When I click on the enhance image button, only the top left portion of the image is displayed.

来源:https://stackoverflow.com/questions/39387332/multiplier-property-not-working-properly-in-todataurl-function-with-cropping-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!