What is the unit of ImageFont.textsize() returned values?











up vote
1
down vote

favorite












I am trying to use PIL to precompute the size that a given line of text will take at a given font and size. PIL seemed to be more or less the only working solution.



I am not sure what is the unit of the returned value of font.textsize(..). The doc doesn't specify it.



The reason why I am asking is because I am confused by the returned values as mentioned here: ImageFont.textsize() seems wrong










share|improve this question


























    up vote
    1
    down vote

    favorite












    I am trying to use PIL to precompute the size that a given line of text will take at a given font and size. PIL seemed to be more or less the only working solution.



    I am not sure what is the unit of the returned value of font.textsize(..). The doc doesn't specify it.



    The reason why I am asking is because I am confused by the returned values as mentioned here: ImageFont.textsize() seems wrong










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I am trying to use PIL to precompute the size that a given line of text will take at a given font and size. PIL seemed to be more or less the only working solution.



      I am not sure what is the unit of the returned value of font.textsize(..). The doc doesn't specify it.



      The reason why I am asking is because I am confused by the returned values as mentioned here: ImageFont.textsize() seems wrong










      share|improve this question













      I am trying to use PIL to precompute the size that a given line of text will take at a given font and size. PIL seemed to be more or less the only working solution.



      I am not sure what is the unit of the returned value of font.textsize(..). The doc doesn't specify it.



      The reason why I am asking is because I am confused by the returned values as mentioned here: ImageFont.textsize() seems wrong







      python python-imaging-library






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 8 at 10:36









      Vic Seedoubleyew

      83




      83
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          The units are pixels, so it tells you how large a canvas you would need to accommodate the text.



          There is no reason it should be the same as any other product's text size.



          There is occasionally a small discrepancy of 3-4 pixels, probably as a result of anti-aliasing.






          share|improve this answer





















          • Thanks a lot for the answer! In that case I don't really get how to compute the size of how much space a given text would take if printed. It seems that pillow assumes a given resolution?
            – Vic Seedoubleyew
            2 days ago










          • Pillow is not in the least bit interested in print sizes or resolutions, it only works in pixels, the same as pretty much all image processing tools. You can make something 100 pixels wide or 1,000 pixels wide and the dpi is completely irrelevant until you come to print it. At that point, if you say you want 300 dpi, your 100 pixels will print at 1/3 inch and your 1,000 pixels will print at 3.3 inches. dpi is just a number you can change at any point - the true measure of how much "quality" you have is how many pixels you have.
            – Mark Setchell
            2 days ago










          • Thanks a lot for sharing! I guess I can find out which resolution my supplier uses for printing, and thus the number of pixels I have. I know the font size I use, which is 9 pt. However it seems like I should in some way multiply that by the resolution, and pass the result to pillow as font size? Otherwise, if I just pass 9 to pillow, it seems that the result would not take into account the amount of pixels I have available. Am I understanding correctly? Thanks again very much for your help
            – Vic Seedoubleyew
            yesterday










          • Yes, exactly... you seem to have the idea of it now.
            – Mark Setchell
            yesterday











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205954%2fwhat-is-the-unit-of-imagefont-textsize-returned-values%23new-answer', 'question_page');
          }
          );

          Post as a guest
































          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote



          accepted










          The units are pixels, so it tells you how large a canvas you would need to accommodate the text.



          There is no reason it should be the same as any other product's text size.



          There is occasionally a small discrepancy of 3-4 pixels, probably as a result of anti-aliasing.






          share|improve this answer





















          • Thanks a lot for the answer! In that case I don't really get how to compute the size of how much space a given text would take if printed. It seems that pillow assumes a given resolution?
            – Vic Seedoubleyew
            2 days ago










          • Pillow is not in the least bit interested in print sizes or resolutions, it only works in pixels, the same as pretty much all image processing tools. You can make something 100 pixels wide or 1,000 pixels wide and the dpi is completely irrelevant until you come to print it. At that point, if you say you want 300 dpi, your 100 pixels will print at 1/3 inch and your 1,000 pixels will print at 3.3 inches. dpi is just a number you can change at any point - the true measure of how much "quality" you have is how many pixels you have.
            – Mark Setchell
            2 days ago










          • Thanks a lot for sharing! I guess I can find out which resolution my supplier uses for printing, and thus the number of pixels I have. I know the font size I use, which is 9 pt. However it seems like I should in some way multiply that by the resolution, and pass the result to pillow as font size? Otherwise, if I just pass 9 to pillow, it seems that the result would not take into account the amount of pixels I have available. Am I understanding correctly? Thanks again very much for your help
            – Vic Seedoubleyew
            yesterday










          • Yes, exactly... you seem to have the idea of it now.
            – Mark Setchell
            yesterday















          up vote
          0
          down vote



          accepted










          The units are pixels, so it tells you how large a canvas you would need to accommodate the text.



          There is no reason it should be the same as any other product's text size.



          There is occasionally a small discrepancy of 3-4 pixels, probably as a result of anti-aliasing.






          share|improve this answer





















          • Thanks a lot for the answer! In that case I don't really get how to compute the size of how much space a given text would take if printed. It seems that pillow assumes a given resolution?
            – Vic Seedoubleyew
            2 days ago










          • Pillow is not in the least bit interested in print sizes or resolutions, it only works in pixels, the same as pretty much all image processing tools. You can make something 100 pixels wide or 1,000 pixels wide and the dpi is completely irrelevant until you come to print it. At that point, if you say you want 300 dpi, your 100 pixels will print at 1/3 inch and your 1,000 pixels will print at 3.3 inches. dpi is just a number you can change at any point - the true measure of how much "quality" you have is how many pixels you have.
            – Mark Setchell
            2 days ago










          • Thanks a lot for sharing! I guess I can find out which resolution my supplier uses for printing, and thus the number of pixels I have. I know the font size I use, which is 9 pt. However it seems like I should in some way multiply that by the resolution, and pass the result to pillow as font size? Otherwise, if I just pass 9 to pillow, it seems that the result would not take into account the amount of pixels I have available. Am I understanding correctly? Thanks again very much for your help
            – Vic Seedoubleyew
            yesterday










          • Yes, exactly... you seem to have the idea of it now.
            – Mark Setchell
            yesterday













          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          The units are pixels, so it tells you how large a canvas you would need to accommodate the text.



          There is no reason it should be the same as any other product's text size.



          There is occasionally a small discrepancy of 3-4 pixels, probably as a result of anti-aliasing.






          share|improve this answer












          The units are pixels, so it tells you how large a canvas you would need to accommodate the text.



          There is no reason it should be the same as any other product's text size.



          There is occasionally a small discrepancy of 3-4 pixels, probably as a result of anti-aliasing.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 8 at 16:31









          Mark Setchell

          83.4k568167




          83.4k568167












          • Thanks a lot for the answer! In that case I don't really get how to compute the size of how much space a given text would take if printed. It seems that pillow assumes a given resolution?
            – Vic Seedoubleyew
            2 days ago










          • Pillow is not in the least bit interested in print sizes or resolutions, it only works in pixels, the same as pretty much all image processing tools. You can make something 100 pixels wide or 1,000 pixels wide and the dpi is completely irrelevant until you come to print it. At that point, if you say you want 300 dpi, your 100 pixels will print at 1/3 inch and your 1,000 pixels will print at 3.3 inches. dpi is just a number you can change at any point - the true measure of how much "quality" you have is how many pixels you have.
            – Mark Setchell
            2 days ago










          • Thanks a lot for sharing! I guess I can find out which resolution my supplier uses for printing, and thus the number of pixels I have. I know the font size I use, which is 9 pt. However it seems like I should in some way multiply that by the resolution, and pass the result to pillow as font size? Otherwise, if I just pass 9 to pillow, it seems that the result would not take into account the amount of pixels I have available. Am I understanding correctly? Thanks again very much for your help
            – Vic Seedoubleyew
            yesterday










          • Yes, exactly... you seem to have the idea of it now.
            – Mark Setchell
            yesterday


















          • Thanks a lot for the answer! In that case I don't really get how to compute the size of how much space a given text would take if printed. It seems that pillow assumes a given resolution?
            – Vic Seedoubleyew
            2 days ago










          • Pillow is not in the least bit interested in print sizes or resolutions, it only works in pixels, the same as pretty much all image processing tools. You can make something 100 pixels wide or 1,000 pixels wide and the dpi is completely irrelevant until you come to print it. At that point, if you say you want 300 dpi, your 100 pixels will print at 1/3 inch and your 1,000 pixels will print at 3.3 inches. dpi is just a number you can change at any point - the true measure of how much "quality" you have is how many pixels you have.
            – Mark Setchell
            2 days ago










          • Thanks a lot for sharing! I guess I can find out which resolution my supplier uses for printing, and thus the number of pixels I have. I know the font size I use, which is 9 pt. However it seems like I should in some way multiply that by the resolution, and pass the result to pillow as font size? Otherwise, if I just pass 9 to pillow, it seems that the result would not take into account the amount of pixels I have available. Am I understanding correctly? Thanks again very much for your help
            – Vic Seedoubleyew
            yesterday










          • Yes, exactly... you seem to have the idea of it now.
            – Mark Setchell
            yesterday
















          Thanks a lot for the answer! In that case I don't really get how to compute the size of how much space a given text would take if printed. It seems that pillow assumes a given resolution?
          – Vic Seedoubleyew
          2 days ago




          Thanks a lot for the answer! In that case I don't really get how to compute the size of how much space a given text would take if printed. It seems that pillow assumes a given resolution?
          – Vic Seedoubleyew
          2 days ago












          Pillow is not in the least bit interested in print sizes or resolutions, it only works in pixels, the same as pretty much all image processing tools. You can make something 100 pixels wide or 1,000 pixels wide and the dpi is completely irrelevant until you come to print it. At that point, if you say you want 300 dpi, your 100 pixels will print at 1/3 inch and your 1,000 pixels will print at 3.3 inches. dpi is just a number you can change at any point - the true measure of how much "quality" you have is how many pixels you have.
          – Mark Setchell
          2 days ago




          Pillow is not in the least bit interested in print sizes or resolutions, it only works in pixels, the same as pretty much all image processing tools. You can make something 100 pixels wide or 1,000 pixels wide and the dpi is completely irrelevant until you come to print it. At that point, if you say you want 300 dpi, your 100 pixels will print at 1/3 inch and your 1,000 pixels will print at 3.3 inches. dpi is just a number you can change at any point - the true measure of how much "quality" you have is how many pixels you have.
          – Mark Setchell
          2 days ago












          Thanks a lot for sharing! I guess I can find out which resolution my supplier uses for printing, and thus the number of pixels I have. I know the font size I use, which is 9 pt. However it seems like I should in some way multiply that by the resolution, and pass the result to pillow as font size? Otherwise, if I just pass 9 to pillow, it seems that the result would not take into account the amount of pixels I have available. Am I understanding correctly? Thanks again very much for your help
          – Vic Seedoubleyew
          yesterday




          Thanks a lot for sharing! I guess I can find out which resolution my supplier uses for printing, and thus the number of pixels I have. I know the font size I use, which is 9 pt. However it seems like I should in some way multiply that by the resolution, and pass the result to pillow as font size? Otherwise, if I just pass 9 to pillow, it seems that the result would not take into account the amount of pixels I have available. Am I understanding correctly? Thanks again very much for your help
          – Vic Seedoubleyew
          yesterday












          Yes, exactly... you seem to have the idea of it now.
          – Mark Setchell
          yesterday




          Yes, exactly... you seem to have the idea of it now.
          – Mark Setchell
          yesterday


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205954%2fwhat-is-the-unit-of-imagefont-textsize-returned-values%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          Popular posts from this blog

          Schultheiß

          Verwaltungsgliederung Dänemarks

          Liste der Kulturdenkmale in Wilsdruff