title: How to compress a picture less than a limit file size using python PIL library?
body: <p>I need to send a picture to another place, where it requires picture size must be less than 512kb.<br>
  I use <code>PIL</code> to deal with my picture which download from internet. so I don't know what will be the next picture's size, code like this:</p>
  
  <pre><code>from PIL import Image
  picture_location = '/var/picture/1233123.jpg'
  compressed_picture_location = '/var/picture/1233123_compressed.jpg'
  im = Image.open(picture_location)
  quality = 75
  im.save(compressed_picture_location, quality=quality)
  im.save()
  </code></pre>
  
  <p>The problem is that the compressed picture's file size is not 75% or 75%*75% of the origin picture, so I have to compress it, stat it, compressed again, I can't select a suitable quality value.</p>
  
  <p>Is there other way to solve this problem?
  Please help or try to give some ideas how to achieve this. </p>