title: How to reliably determine jpeg image resolution with Pillow
body: <p>If the Pillow Info DPI field has no value, how can an image's resolution be determined? Note that this is for jpeg files for which other image processing programs are able to correctly identify the resolution. Following is the code I am using to read the jpeg dpi value.</p>
  
  <pre><code>from PIL import Image
  jpgfile='someimage.jpg'
  im = Image.open(jpgfile)
  dpi = im.info.get('dpi')
  print("\n dpi: ", type(dpi), "  ", dpi)
  </code></pre>
  
  <p>The expected output is: </p>
  
  <pre><code>dpi:  &lt;kbd&gt; class 'tuple' (999, 999)
  </code></pre>
  
  <p>where '999' is the x and y resolution. </p>
  
  <p>However, many images result in the following output</p>
  
  <pre><code>dpi class 'NoneType' None
  </code></pre>
  
  <p>In these instances (which are all too common), how can I get the image's resolution? </p>