Page 1 of 1

calculate image size in a2-a6 formats

Posted: 2016-04-30T03:54:42-07:00
by mstdmstd
Hi all,
Sorry for offtop, this is not imagemagick question, but I wrote here as many people are knowlageble about images sizes and related questions...
I have some kind of image editor written using php/javascript, which is based on fabricjs library (http://fabricjs.com/) and admin, logged to site has to select a2-a6 formats and orientation as portrait / landscape.
Here http://www.papersizes.org/a-sizes-in-pixels.htm I see that size of image depends not only from selected format and orientation, but also from monitor of admin.

Here https://www.sven.de/dpi/ there is DPI Calculator / PPI Calculator, say on my side it is 115.942, as I have laptop 19 inch, Resolution : 1920x1080 pixels

The question is how to calculate width and height of generated image?
That is known that size in mm = pixels * pixels in 1mm.

We can not calculate programmatically ppi value by using javascript... Is it so?

Admin MUST KNOW it... say in image editor show link to dpi/ppi Calculator and admin can get it there and enter this value in.
After admin selected his ppi value by data in http://www.papersizes.org/a-sizes-in-pixels.htm table programm must to select valid width/height in pixels, say as example
a5/portrait for my 115.94 PPI I must get 874 x 1240 pixels, as I need to get right column(3rd column) from range of my ppi. Is it so?
Entering all data template of image with all parameters is saved and image is generated.
Question is if admin reopens this template(maybe on ther device) with generated image has he enter his ppi of this devices and recalculate the image size again?

Thanks for advice!

Re: calculate image size in a2-a6 formats

Posted: 2016-04-30T06:48:20-07:00
by snibgo
mstdmstd wrote:That is known that size in mm = pixels * pixels in 1mm.
No.

size_in_mm = pixels / pixels_in_1mm.

Or:

Pixels = pixels_in_1mm * size_in_mm

If your monitor is 115.94 PPI (pixels per inch),
then one inch is 25.4mm so the monitor is 115.94/25.4 = 4.565 pixels per mm.

For example, A4 paper is 297mm x 210mm.
At 4.565 pixels per mm, this is 297*4.565 = 1355.805 pixels by 958.65 pixels.