I want to extract the dimensions of the image from the URL in google Sheet. Found this Library that does exactly what I am after.
https://github.com/tanaikech/ImgApp#getsize
But I am very new to this scenario and wondering what exactly I should use in the script editor. If I follow the above I can't get the results.
Please help.
Thanks
When I saw your provided sample Spreadsheet, it seems that the Spreadsheet and your script are as follows.
function myFunction() {
var blob = DriveApp.getFileById(fileId).getBlob();
var res = ImgApp.getSize(blob);
var width = res.width;
var height = res.height;
}
=myFunction(A2)
to a cell. But your script doesn't retrieve the value.DriveApp.getFileById(fileId)
cannot be used because of the limitation.When these points are reflected in the script for achieving your goal, it becomes as follows.
Please replace your current script with the following script and save the script. And, please put a custom function of =myFunction(A2)
to a cell. By this, the width and height are returned.
function myFunction(url) {
const blob = UrlFetchApp.fetch(url).getBlob();
const { width, height } = ImgApp.getSize(blob);
return [[width, height]];
}
When this modified script is used for your sample Spreadsheet, it becomes as follows.