1

I want to use UrlFetchApp to request and hope to get response.

var url = "https://i.imgur.com/dCv0PzY.gif";
var res = UrlFetchApp.fetch(url,{
      'headers': {'Content-Type': 'image/png'}});
Logger.log(res);

But response is too much data.

Like the picture below.

enter image description here

I read other discussion

There is a method getBlob(),but I only get the string "Blob" after use it.

And the second discussion

It uses content attribute,but I get syntax error,too.(the method not exist).

.

.

Is this a Base64 data or other type data?

And how can I get the image information(width,height,etc)

on the recommanded way?

Thank you.

Hsinhsin Hung
  • 343
  • 1
  • 2
  • 12

1 Answers1

2

You can access Drive API through Advanced Google services to retrieve some metadata:

Sample script:

function getImageMeta(){
var url = "[IMAGE_LINK]";
var res = UrlFetchApp.fetch(url,{
      'headers': {'Content-Type': 'image/png'}});
  var file = DriveApp.createFile(Utilities.newBlob(res.getContent()).setName('test'+Math.floor(Math.random()*100)));
  var meta = Drive.Files.get(file.getId()).imageMediaMetadata;
  Logger.log(meta)
  file.setTrashed(true);
}

References:

Community
  • 1
  • 1
TheMaster
  • 45,448
  • 6
  • 62
  • 85