title: Insert images as encoded file to LMDB using Python
body: <p>I'm trying to insert a bunch of images into the LMDB format using the following snippet:</p>
  
  <pre><code>with env.begin(write=True) as txn:
  for i in range(N):
      datum = caffe.proto.caffe_pb2.Datum()
      datum.channels = X.shape[1]
      datum.height = X.shape[2]
      datum.width = X.shape[3]
      datum.data = X[i].tobytes()  # or .tostring() if numpy &lt; 1.9
      datum.label = int(y[i])
      str_id = '{:08}'.format(i)
  
  # The encode is only essential in Python 3
      txn.put(str_id.encode('ascii'), datum.SerializeToString())
  </code></pre>
  
  <p>However, as the uncompressed bytes are written on the disk, the resultant file is so huge!! Accordingly, I'm wondering how I can set the encoding property to JPG in python. I am already aware that the very option is available in C++ api.</p>
  
  <p>Thanks in advance</p>