2

I have resized image successfully using GAE images api now i again want to store the resized image in blob-store how can i do it kindly help. Here is the code

img = images.Image(blob_key=user.profile_pic)
img.resize(width=80, height=100)
img.im_feeling_lucky()
thumbnail = img.execute_transforms(output_encoding=images.JPEG)

if i use this code it displays the resized image but i want to store it again in blob store.

self.response.headers['Content-Type'] = 'image/jpeg'
self.response.out.write(thumbnail)
shahzeb akram
  • 906
  • 7
  • 24
  • 2
    Blobstore does not allow you to write an image. To use Blobstore you have to upload the resized image. A better way is to use GCS (Google cloudstorage). You can use the blobstore API to store a blob in GCS and you can use the Google Cloud Storage client library to write a gcs file. – voscausa Jan 10 '17 at 23:37
  • Possible duplicate of [How to save a rotated image which was stored in GAE Blobstore?](http://stackoverflow.com/questions/34633213/how-to-save-a-rotated-image-which-was-stored-in-gae-blobstore) – Dan Cornilescu Jan 10 '17 at 23:46
  • @DanCornilescu is there a way to get the serving url of resized image. So that we can display the resized image with other data. – shahzeb akram Jan 11 '17 at 04:17
  • Also via the blobstore API mentioned by @voscausa, see http://stackoverflow.com/a/39082226/4495081 for details – Dan Cornilescu Jan 11 '17 at 04:24
  • Actually i do not want to use the GCS. – shahzeb akram Jan 11 '17 at 04:43
  • Can we render this resized image directly on webpage. – shahzeb akram Jan 11 '17 at 04:46
  • 1
    You can use a get_serving_url in your webpage. This URL format also allows dynamic resizing and cropping with certain restrictions. Look for: google.appengine.api.images.get_serving_url – voscausa Jan 12 '17 at 02:58
  • thanks @voscausa i figured it out :) – shahzeb akram Jan 12 '17 at 06:41

1 Answers1

1

Here is the solution after getting the serving url we can simply pass arguments in the link to perform operations on the image.

img = images.Image(blob_key=user.profile_pic)
url = images.get_serving_url(user.profile_pic)        
url = url + "=s80" #if i want a thumbnail  
shahzeb akram
  • 906
  • 7
  • 24