Calculating image size in inches or dpi from pixels using php

I need to calculate the approximate size of the image in inches, assuming 300 dpi.

I have the size of the target image, and I want to show the user if the image they uploaded is adequate, or it will need to be stretched and offer various conditional messages based on this.

I already have the height and width in pixels, I just need to know the math, I think.

+3
source share
2 answers

DPI = "dots per inch". One dot = one pixel.

300 pixels at 300 dpi: 1 inch You can solve it :-)

+6
source

Given that dots == pixels:

= /

, 900 , 300 dpi 3 .

+1

Source: https://habr.com/ru/post/1775822/


All Articles