code: def jpgMin(file, force=False):
      
      if not os.path.isfile(file+'.original') or force:
          data = _read(file, 'rb')
          _save(file+'.original', data, 'w+b')
          print 'Optmising JPG {} - {:.2f}kB'.format(file, len(data)/1024.0),
          url = 'http://jpgoptimiser.com/optimise'
          parts, headers = encode_multipart({}, {'input': {'filename': 'wherever.jpg', 'content': data}})
          req = urllib2.Request(url, data=parts, headers=headers)
          try:
              f = urllib2.urlopen(req)
              response = f.read()
              f.close()
              print ' - {:.2f} - {:.1f}%'.format(len(response)/1024.0, 100.0*len(response)/len(data))
              _save(file, response, 'w+b')
          except:
              print 'Oops!! Failed :('
              return 1
      else:
          print 'Ignoring file: {}'.format(file)
      return 0
docs: Try to optimise a JPG file.
  
      The original will be saved at the same place with '.original' appended to its name.
  
      Once a .original exists the function will ignore this file unless force is True.