Exemplo n.º 1
0
 def _to_base_type(self, value):
     """
     Transforming the image and saving it to blobstore
     """
     img = Image(self._img_data)
     if self._width > 0 or self._height > 0:
         img.resize(width=self._width, height=self._height)
     img.im_feeling_lucky()
     return img.execute_transforms(output_encoding=images.JPEG)
Exemplo n.º 2
0
 def _to_base_type(self, value):
     """
     Transforming the image and saving it to blobstore
     """
     img = Image(self._img_data)
     if self._width > 0 or self._height > 0:
         img.resize(width=self._width, height=self._height)
     img.im_feeling_lucky()
     return img.execute_transforms(output_encoding=images.JPEG)
Exemplo n.º 3
0
def fiximage(data):
    """Take an uploaded image, call I'm feeling lucky
  and put it back out to the user.
  """
    logging.info("Transforming image...")
    logging.info("In data size: %d" % (len(data), ))

    image_in = Image(str(data))
    image_in.im_feeling_lucky()

    image_out = ByteArray()
    image_out.write(image_in.execute_transforms())

    logging.info("Out data size: %d" % (len(image_out), ))
    return image_out
def store_picture_from_content(content, mime_type='application/octet-stream'):
    img = Image(content)
    img.resize(width=800, height=800)
    img.im_feeling_lucky()
    img_type = PNG if 'png' in mime_type else JPEG
    img = img.execute_transforms(output_encoding=img_type)

    # create file
    file_name = files.blobstore.create(mime_type=mime_type)
    with files.open(file_name, 'a') as f:
        f.write(img)

    # Finalize the file
    files.finalize(file_name)

    # Get the file's blob key
    blob_key = files.blobstore.get_blob_key(file_name)
    return get_serving_url(blob_key), blob_key
Exemplo n.º 5
0
 def post(self):
      img = Image(self.request.get('file'))
      
      img.im_feeling_lucky()
      lucky = img.execute_transforms()
      self.render(image=lucky)