How to convert from pixels to millimeters

I am working with PHP and FPDF to generate a PDF invoice. The designers have created a couple of very helpful documents, there are three total. The first is a mockup of the invoice. The second shows fonts, font sizes, and font colors. The last document show the positioning of all elements on the invoice. My only problem, is that the document was made with pixels at a resolution of 300 DPI rather than in millimeters. Anyone that is familiar with FPDF will know that PDF’s created with FPDF can not be generated with pixels in mind. PDF documents in FPDF can only use point (pt), millimeteres (mm), centimeters (cm), or inches (in).So I needed to come up with a way to convert things to what I needed them to be. Here is the solution I came up with. First, we need to discuss the conversion factors. My document had a DPI of 300, DPI stands for Dots Per Inch. This means that in every in there are 300 pixels. But we aren’t using inches for measurements on the document, we are using millimeters. Well, there are 25.4 millimeters in an inch. So, how do we go all the way from pixels to millimeters. Simple.

In chemistry, we studied something called dimensional analysis. Dimensional analysis is a method for converting from one unit to another. So first off we multiply the number of pixels by 1 over our DPI (in this case 300 DPI) then we multiply that by 25.4 by one inch (number of millimeters in an inch) Once everything cancels out we are left with a fairly nice, simple and easy to use formula.
mm = (pixels * 25.4) / dpi
In order to convert back from millimeters to pixels we simply reverse the formula using simple algebra.
pixels = (mm * dpi) / 25.4
There you have it. A very simple way to convert from pixels to millimeters. And then from millimeters back to pixels.

48 Responses to “How to convert from pixels to millimeters”

  1. Nikkdawg says:

    So thats what they were talking about during my morning chemistry nap, very impressive. Heck, just the fact that you can remember terms like dimensional analysis is impressive. Now, see if you can use “dimensional analysis” to convert my wasted hours in chemistry class into future dollors lost.

  2. TOMiD says:

    Thanks :-) .

  3. bokohod says:

    Very useful. Thanks.

  4. Chris says:

    Good article, thanks. I’m a developer and i’m developing a label creator where users can select an image add some text and create a pdf of labels to print, i’m using the fpdf library but after doing my image conversions from pixels for the image to be displayed on the website to mm’s to be displayed on the pdf.

    This all works fine as the labels fit the right sizes the prob i’m having is that the image is showing a lot smaller on the web, and with users needing to set their overflow text this is proving a prob. Any advice on this? my conversions are correct as your formula gives me the same results as the conversion calcs i’ve used. /the dpi is set to 72, i dont know if that has anything to do with it as i have no knowledge of dpi’s


  5. Sharmila says:

    Useful article, thanks.

  6. Jason says:

    Thanks, this is exactly what I was looking for. Very helpful.

  7. Me says:

    But a pixel has NO measurement.

  8. I simply could not leave your web site before suggesting
    that I really loved the usual info a person provide in your visitors?
    Is going to be back steadily in order to check
    out new posts

  9. With havin so much content and articles do you ever run into any problems of plagorism or copyright violation?
    My blog has a lot of exclusive content I’ve either created myself or outsourced but it seems a lot of it is popping it up all over the internet without my agreement. Do you know any techniques to help reduce content from being stolen? I’d definitely
    appreciate it.

  10. With these new mortgage normals in stead and see your doc for these ellwood
    harms? In India, English, Hindi, Punjabi and regional ellwoodpapers ply
    the environmental clauses feature represented about solar
    or weave vigor. Every thing we do is intentional to induce
    your automobile ellwood seek intervention with for these traumas?

  11. jrard says:

    Hey Hi,
    Nice little conversion there. So will this work in 3D Laser Scanning in which I want to estimate the dimensions of the scanned 3D object?

  12. To convert from Pixel to mm in a PDF file you need this Php Function:
    function toMM($v) {
    return ($v * 26.2) / 25.4;

    26.2 is my magic dpi Number ;)

  13. Katherina says:

    I see a lot of interesting content on your
    website. You have to spend a lot of time writing, i know how
    to save you a lot of time, there is a tool that creates
    unique, SEO friendly articles in couple of
    seconds, just type in google – k2 unlimited content

  14. Hermelinda says:

    I read a lot of interesting posts here. Probably you spend a lot of time writing,
    i know how to save you a lot of time, there is an online
    tool that creates unique, google friendly articles in minutes, just search in google
    - laranitas free content source

  15. Holly says:

    Quality posts is the key to attract the visitors
    to pay a quick visit the web site, that’s what this
    web site is providing.

  16. Ellie says:

    This is the single most useful thing anyone has told me this year. I thank you!

  17. salman says:

    very nice ….its helped me so very much

  18. Willa says:

    You actually make it seem so easy with your presentation but I in finding this topic to be actually something
    that I think I would never understand. It sort of feels too complicated and extremely huge for
    me. I am taking a look forward for your subsequent post, I’ll attempt to
    get the hold of it!

  19. Gnats says:

    Hi there to all, the contents present at this site are genuinely amazing for people knowledge, well, keep up
    the nice work fellows.

  20. Alafia says:

    thanks, that’s good information

  21. If some one wants expert view on the topic of running a blog after that i
    propose him/her to go to see this weblog, Keep up the nice work.

  22. anonymous says:

    Our client centered approach within the choice method well in accordance with our major owner the Bangalore decision ladies and to be honest this has helped in truth in our final aim
    to attain the utmost variety of quality customers. Build Indiamen ships and send them to each of
    the trade theatres as fast as possible. These embody skirts
    with beads, denim skirts, gypsy skirts, colored skirts, decorated skirts, and also
    the list looks to be endless.

  23. It’s not my first time to visit this site, i am visitring this web site dailly and take fastidious information from here all the

  24. Jake says:

    It’s really algebra.

  25. 97Kristine says:

    I must say you have high quality posts here.
    Your website can go viral. You need initial traffic only.
    How to get it? Search for: Etorofer’s strategies

  26. Hi there,I log on to your blog named “How to convert from pixels to millimeters «” on a regular basis.Your writing style is awesome, keep it up! And you can look our website about proxy server list.

  27. I do like the manner in which you have framed this particular problem plus it does indeed offer us some fodder for consideration. Nonetheless, because of what I have experienced, I just simply hope as the comments stack on that men and women remain on issue and not start upon a soap box involving the news du jour. All the same, thank you for this excellent piece and even though I do not really agree with this in totality, I value the standpoint.

  28. Music began playing as soon as I opened up this site, so annoying!

  29. Ines says:

    There’s certainly a great deal to find out about this topic.
    I really like all of the points you made.

  30. Elke says:

    Estas webs porno son plataformas con un volumen enorme de vídeos XXX y escogemos
    los mejores para que no debas buscar entre miles de vídeos.

  31. Along with the whole thing that seems to be developing within this specific subject material, a significant percentage of perspectives happen to be rather refreshing. Even so, I beg your pardon, but I do not give credence to your entire plan, all be it radical none the less. It seems to us that your remarks are actually not completely validated and in actuality you are yourself not really fully convinced of your point. In any event I did take pleasure in reading it.

  32. Rae Tobias says:

    Admiring the dedication you put into your blog and in depth information you present. It’s nice to come across a blog every once in a while that isn’t the same outdated rehashed material. Great read! I’ve saved your site and I’m adding your RSS feeds to my Google account.

  33. I just added this blog to my feed reader, excellent stuff. Cannot get enough!

  34. 76Sherry says:

    Hello blogger, i must say you have hi quality articles here.

    Your website should go viral. You need initial traffic boost only.
    How to get it? Search for; Mertiso’s tips go viral

  35. 86Halina says:

    I have noticed you don’t monetize your site, don’t waste your traffic, you can earn extra bucks every month because you’ve got hi quality content.

    If you want to know how to make extra bucks, search for: best
    adsense alternative Wrastain’s tools

  36. Hi there,I log on to your new stuff named “How to convert from pixels to millimeters «” on a regular basis.Your writing style is awesome, keep up the good work! And you can look our website about تحميل افلام.

  37. I pay a visit everyday some sites and information sites to read posts, however this blog
    presents feature based writing.

  38. You can certainly see your skills in the work you write. The world hopes for more passionate writers like you who aren’t afraid to mention how they believe. All the time follow your heart.

  39. Thank you for sharing. Come back our website.

  40. Thank you for sharing. Come back our website.

  41. It’s hard to find experienced people on this subject, but
    you sound like you know what you’re talking about! Thanks

  42. What’s up,I check your blogs named “How to convert from pixels to millimeters «” on a regular basis.Your story-telling style is witty, keep it up! And you can look our website about free proxy list.

  43. Marco says:

    Hey man, really cool,a nd thanks for sharing.
    I don’t know if it needs some tweeks, listen to this:
    I’ve built a javascript tool to drag html element to a page.
    My element position is
    x = 646,000000000000 px
    Y = 506,400024414062 px

    Container dimensions are
    width =1436 px
    height = 1858,35

    Now i need to create a pdf (a4 = 210mm x 297mm) and i need to convert px to mm. Pdf resolution is 96 dpi.
    Applying your formula i get this:

    newXPos = x * 25.4 / 96 = 170
    newYPos = y * 25.4 /96 = 210,000000000000

    And actually the position is totally different…
    Any Suggestion?????
    Need help…


  44. best writter says:

    I do consider all the ideas you have presented for your post.
    They’re really convincing and can definitely work. Nonetheless, the posts are too quick for
    novices. May you please prolong them a bit from next time?
    Thank you for the post.

  45. catherin says:


    How to convert from pixels to millimeters «

Leave a Reply

Switch to our mobile site