Google script : how to resize image in blob?

后端 未结 3 776
小蘑菇
小蘑菇 2020-12-22 07:07

I have a blob containing an image that is remotely loaded and created in Google Drive:

var response = UrlFetchApp.fetch(fileURL);
var fileBlob = response.get         


        
3条回答
  •  攒了一身酷
    2020-12-22 07:30

    Images in Apps Scripts are resized by grabbing the blob from the request and placing it in whatever app you're using with a width or height attribute (these scale both width and height of the image, just use whichever is most useful for you).

    It looks like you're trying to resize an image on its way to a drive folder though, that should be done using a server/serverless function (maybe look into a Node-based resize tool that you can shove into a Google Cloud Function?).

    You can also try to create a Google Doc and paste the image into the doc, then get the image blob and save it into your folder.

提交回复
热议问题