1

I have a problem saving my canvas. I think that is because my canvas is too large. I have asked for help here:

Elements on the canvas disappear w/ jsfiddle

canvas.toDataURL() for large canvas

… but no success.

My problem is the next:

I have a canvas for example with these dimensions: 1123x1965 pixels and I need to resize to 29.7x52 centimeters and put them in 300dpi.

My rational was as follows:

  • After the edited template, convert to full size and then save a png image to the actual size in pixels, already multiplied by 300 dpi. Made this calculation:

29.7 centimeters: 29.7*300 = 8910

52 centimeters: 52*300 = 15600

The problem on using this is basically canvas disappear. Please look this: Elements on the canvas disappear w/ jsfiddle

And todataurl function don’t work: canvas.toDataURL() for large canvas

  • Then use the library imagemagick convert to 300 dpi, like this command: convert test.png -units PixelsPerCentimeter -density 300 test2.png

Anyone can help me?

Thank You.

Community
  • 1
  • 1
ptCoder
  • 2,229
  • 3
  • 24
  • 38

2 Answers2

2

Just divide what you already have on 2.54 to get pixels based on inches. Although, the more correct term is PPI instead of DPI (as dots on paper behave a little different than pixels on a screen).

29.7 cm * 300 PPI / 2.54 = 3508 pixels

52.0 cm * 300 PPI / 2.54 = 6142 pixels

(Are you sure about 52 cm is correct ? (A4 short side x2, ie A3, is 42 cm)).

1

DPI means dots per inch, not dots per centimeter. 300 DPI(dot/in) = 118 dpcm (dot/cm)

The calculations should be:

29.7 centimeters: 29.7*118 = 3504.6

52 centimeters: 52*118 = 6136

I hope this helps solving your problem. (I cannot give comments, yet. So I put this as an answer)

Mike de Dood
  • 393
  • 1
  • 10
  • Thank You very much. Yes, I think that you are correct. I'm trying implementing it today. Thank You very much. – ptCoder May 21 '13 at 15:51