Hi,

I'm using the FPDF class from http://www.fpdf.org - however, when I calculate an image size with getimagesize();

getimagesize();

I then need to convert the first two items returned in the image_size_array to mm?

Anyone have a quick conversion from pixels to mm?

Thanks,
R

    Ah ha,

    I'm doing this now, seems to work - 1px = 0.353mm

    Thus

    $w_mm = $image_size_array[0]*0.353;

    This is right I think... anyone else have this issue...?

      Um... you can't really do that. Pixel sizes change everytime you change monitor resolutions, and vary even more between different monitors and different monitor brands...

        Not true superwormy, trust me I've been making pixel icons for years and know my pixer's inside out, upside down, tonsils & intestines!

        getimagesize(); works to retrieve the pixel size of the file, not it via the display of one's puter..

        Its working fine on a PC 1024X768/ MAC 1280X854..

        R

          No kidding they recieve the pixel size of the file, BUT ACTUAL PHYSICAL PIXEL SIZES VARY!

          Look at the pixel size on a 1600x1200 monitor vs. the pixel size on your cell phone or a graphing calculator. Guess what? They're different!

          Most comptuer monitors have a pixel size of 0.26 mm to 0.35 mm.

          Large presentatoin monitors sometimes use .48mm pixels.

          But again, pixel size is dependent on the resolution of the persons display. Switch your monitor to 640x480 and try to measure the size of a pixel on your monitor. Now switch to 1280x1024 and see if you can still measure it.

            It should also be noted that pixels on most computer monitors arn't square, they're slightly rectangular. This also varies depending on resolution and monitor brand.

              My question would be: why is it an issue? Because pixels are different sizes in different environments (and different resolutions in the same environment), mm aren't that useful for screen display anyhow.

              Rendering for print is another matter. Once you whack the image on paper its size isn't going to go changing when someone else looks at it. But then, printed pixels are generally a lot smaller than screen pixels.

                Amen to Weedpacket, I can't see why you'd ever make this calculation either...

                  Note that the original post has been edited so that it now makes sense.

                  The FPDF site you link to lists this exact question as Number 10 in its FAQ.

                  http://www.fpdf.org/en/FAQ.php#10
                  10. I'd like to put my image in real size in the PDF. How can I convert pixels to mm?
                  An image has no "real size". The dimension it is given in the document is arbitrary. Except if you want to impose a particular resolution (for instance 72dpi, which is the one typically used on screen display), in which case the ratio between the pixel width and the resolution gives the dimension.

                  Note as before that printed documents have a higher resolution, though most these days can manage adequate results given a 72dpi image - which in other units is 2.8 pixels/mm (72dpi is typical Mac res and the idea is that it corresponds to one pixel per point). Windows machines typically run at 96dpi (or 3.8 pixels/mm) - all else being equal, which it hardly ever is.

                  But there's nothing stopping you using higher resolutions (e.g. 360dpi) except for the increase in document size. It's a tradeoff.

                    Write a Reply...