1

I'm trying to generate an image 1800px 2400px with 150DPI but I always get 72DPI.

var image = canvas.toDataURL({
  left:150,
  top: 100,
  width: 180,
  height: 240,
  multiplier: 10
}).replace("image/png", "image/octet-stream")

How can I get a PNG with 150DPI ?

xmojmr
  • 8,073
  • 5
  • 31
  • 54

1 Answers1

1

By default, your images are created in 72DPI. Since you send your image to server, you can convert the image to 150DPI using ImageMagick for example.

In PHP use this command:

$img150 = "convert input72image.png -units PixelsPerCentimeter -density 60x60 output150image.png;
exec ($img150);

PNG images are not converted in DPI but in "PixelsPerCentimeter". 60 PixelsPerCentimeter are iqual to 152,4 DPI.

See these posts: What is the best practice to export canvas with high quality images? and canvas.toDataURL() for large canvas

I hope it helps.

Community
  • 1
  • 1
ptCoder
  • 2,229
  • 3
  • 24
  • 38
  • I don't have access to exec or any function of the like... can you add a php image magick object to demonstrate? – Shmack Nov 20 '20 at 21:05