I have an image and I want to resize this.
App Script code:
var fileId = \'idImage\';
var img = DriveApp.getFileById(fileId).getBlob().;
newFile.getB
Calling insertImage() returns an InlineImage object (or an OverGridImage if you're working with a spreadsheet.)
In either case, you could use a function like this to resize the image:
function resizeImg(img, targetHeight) {
var height = img.getHeight();
var width = img.getWidth();
var factor = height / targetHeight;
img.setHeight(height / factor);
img.setWidth(width / factor);
};
This approach ensures the image gets scaled proportionally, to your target height (in pixels).
Example usage:
var myImg = newFile.getBody().insertImage(0, img);
resizeImg(myImg, 60);