I\'ve made my way through all threads about this topic. From blob to URLs and more, to insert an image into a cell via apps-script but nothing seems to work. And most of the pos
I believe your goal as follows.
insertImage
with the blob.For this, how about this answer?
Training_folder
, an error occurs.I thought that these might be the reason of your issue. So I would like to propose the following modification.
When your script is modified, please modify as follows. In this modification, "ImgApp" which is Google Apps Script library is used. So before you run the script, please install the GAS library. You can see how to install it at here.
while(filesIter.hasNext()){ // While loop for all files in folder found by name
var file = filesIter.next();
var filename = file.getName(); // Get Name
var filesize = file.getSize() / 1024; // Get size in kb
var file_id = file.getId(); // Get ID
var file_url = file.getUrl(); // Get Url to file
sheet.insertImage(file.getBlob(), i, 1); // Insert Image
Logger.log(filename + filesize + file_id);
Logger.log(filesize);
Logger.log(file_id);
i++; // increment i by one
}
while(filesIter.hasNext()){
var file = filesIter.next();
if (file.getMimeType().indexOf("image") != -1) {
var blob = file.getBlob();
var size = ImgApp.getSize(blob);
if (size.width * size.height > 1048576) {
var resized = ImgApp.doResize(file.getId(), 512);
blob = resized.blob;
}
sheet.insertImage(blob, i, 1); // Insert Image
i++; // increment i by one
}
}