0

I am using the toDataURL method of FabricJS with a multiplier. However, when I try to download and open the file, in paint for example, it throws the following error:

This is not a valid bitmap file, or its format is not currently supported

However, if I don't use the multiplier, it works. I am using Chrome and my dimensions when multiplied are 11610 x 7800 (initially it is 774 x 520) so it is within the bounds stated here: Maximum size of a <canvas> element

Here is my canvas HTML:

 <canvas id ="c"></canvas>

Here is my canvas creation JavaScript:

var canvas = new fabric.Canvas('c', {
});

canvas.setWidth(774);
canvas.setHeight(520);

Example 1: No multiplier (works):

var img = canvas.toDataURL({
format: "png",
});

document.write('<img src="' + img + '"/>');

Example 2: Multiplier (doesn't work/bitmap error):

var img = canvas.toDataURL({
format: "png",
multiplier: 15
});

document.write('<img src="' + img + '"/>');

Update:

This appears to only be happening with files that have a dimension larger than 10,000 pixels.

Community
  • 1
  • 1
Kode
  • 3,073
  • 18
  • 74
  • 140
  • I am using Chrome so it is less than the max in this case. – Kode Oct 06 '15 at 03:45
  • 15x774= 11610 < 32767 – Kode Oct 06 '15 at 03:47
  • 1
    Apologies, I have updated my post. I have also noticed that it will open in Paint.NET but not Paint, but within Paint I can create images with dimensions greater than 11610x7800 so I am unsure why it can't open something that is 11610x7800. – Kode Oct 06 '15 at 03:49
  • 1
    Oh missed that point so you mean that the image is actually visible in the browser too? Then the problem comes from Paint and I can't help and am not sure if SO is the right place. – Kaiido Oct 06 '15 at 03:50
  • 1
    Yes, if I go the route in post, I can inspect the element using the document write method and it displays as 11610x7800. I then download it via a save as... but when I try to open in Paint, I get the error – Kode Oct 06 '15 at 03:51
  • Can you try setting your canvas this size and then call the toDataURL without multiplier ? – Kaiido Oct 06 '15 at 03:53
  • 1
    Yes, when I try that, I get the same error. Looks like it may be paint then... – Kode Oct 06 '15 at 03:54
  • Then the problem has nothing to do with FabricJS... – Kaiido Oct 06 '15 at 03:58

0 Answers0