I want to import an image to Google Slides over Google Apps Script after the instruction Google Developers - How to...
function createImage(presentationId) {
// Add a new image to the presentation page. The image is assumed to exist in
// the user's Drive, and have 'imageFileId' as its file ID.
var requests = [];
var pageId = 'g1fe0c....';
var imageId = 'MyImage_01';
var imageUrl = DriveApp.getFileById('0B6cQESmLJfX...').getUrl();
var emu4M = {
magnitude: 4000000,
unit: 'EMU'
};
requests.push({
createImage: {
objectId: imageId,
url: imageUrl,
elementProperties: {
pageObjectId: pageId,
size: {
height: emu4M,
width: emu4M
},
transform: {
scaleX: 1,
scaleY: 1,
translateX: 100000,
translateY: 100000,
unit: 'EMU'
}
}
}
});
// Execute the request.
var response = Slides.Presentations.batchUpdate({
requests: requests
}, presentationId);
}
But for every image-format I tried, there is an error message in Google Apps Script:
Invalid requests[0].createImage: The provided image is in an unsupported format.
Drive- and Slides API is activated in Google Advanced Services. The folder and the file has a public share.
Does anyone use the command DriveApp.getFileById() with subsequent export to Google Slides successfully?
The provided image is in an unsupported format.
of your error message, can we ask you about what the format of image you want to use is? - Tanaike