docs: def _pack_image(filename, max_size, form_field='image', f=None):
          """Pack image from file into multipart-formdata post body"""
          # image must be less than 700kb in size
          if f is None:
              try:
                  if os.path.getsize(filename) > (max_size * 1024):
                      raise TweepError('File is too big, must be less than %skb.' % max_size)
              except os.error as e:
                  raise TweepError('Unable to access file: %s' % e.strerror)
  
              # build the mulitpart-formdata body
              fp = open(filename, 'rb')
          else:
              f.seek(0, 2)  # Seek to end of file
              if f.tell() > (max_size * 1024):
                  raise TweepError('File is too big, must be less than %skb.' % max_size)
              f.seek(0)  # Reset to beginning of file
              fp = f
  
          # image must be gif, jpeg, or png
          file_type = mimetypes.guess_type(filename)
          if file_type is None:
              raise TweepError('Could not determine file type')
          file_type = file_type[0]
          if file_type not in ['image/gif', 'image/jpeg', 'image/png']:
              raise TweepError('Invalid file type for image: %s' % file_type)
  
          if isinstance(filename, six.text_type):
              filename = filename.encode('utf-8')
  
          BOUNDARY = b'Tw3ePy'
          body = []
          body.append(b'--' + BOUNDARY)
          body.append('Content-Disposition: form-data; name="{0}";'
                      ' filename="{1}"'.format(form_field, filename)
                      .encode('utf-8'))
          body.append('Content-Type: {0}'.format(file_type).encode('utf-8'))
          body.append(b'')
          body.append(fp.read())
          body.append(b'--' + BOUNDARY + b'--')
          body.append(b'')
          fp.close()
          body = b'\r\n'.join(body)
  
          # build headers
          headers = {
              'Content-Type': 'multipart/form-data; boundary=Tw3ePy',
              'Content-Length': str(len(body))
          }
  
          return headers, body