Reputation: 5
so I tried this
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody;
function Issac() {
var fileId = '1QAsyRGeQvz8L2VesbItTCHAEQKN0P2T6';
var img = DriveApp.getFilesByName('shrok.jpg');
var blobFish = UrlFetchApp.fetch("https://steamuserimages-a.akamaihd.net/ugc/949582948907306301/A7560C16C1D8D9778C52D24BBB86184E30F70E41/");
doc.getChild(0).asParagraph().appendInlineImage(blobFish.getBlob());
}
But im not even sure how to get started on setting the width or setting the height of the image
Upvotes: 0
Views: 2224
Reputation: 9571
Use .setHeight()
and .setWidth()
on the image returned by .appendInlineImage()
.
I've included here a way to scale it by percentage, but both of those height/width methods accept pixel values. You can modify to fit your needs.
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody;
function Issac() {
var fileId = '1QAsyRGeQvz8L2VesbItTCHAEQKN0P2T6';
var img = DriveApp.getFilesByName('shrok.jpg');
var blobFish = UrlFetchApp.fetch("https://steamuserimages-a.akamaihd.net/ugc/949582948907306301/A7560C16C1D8D9778C52D24BBB86184E30F70E41/");
var image = doc.getChild(0).asParagraph().appendInlineImage(blobFish.getBlob());
var scale = 0.5; // scale the image by 50%
image.setWidth(image.getWidth() * scale);
image.setHeight(image.getHeight() * scale);
}
Upvotes: 3