Error: Uncaught ScriptError: Exception: The image you are trying to use is invalid or corrupt.
in sidebar images are coming through api in base64 encoding, once click on image it should insert/(copy/clone) in slide.
my script with url of image is working fine when passing in insertImage() but with base64 as argument its throwing an error working.
Sidebar.html (working fine)
$.ajax({
.......
$('#images_assets').append($('<li>')
.attr('data-imgname', v.Id)
.html([
$('<img>')
.attr('class', 'img-mlc1')
.attr('id', 'img-mlc-' + v.Id)
.attr('src', 'data:image/png;base64,' + jqXHR.responseText)
.attr('draggable', false),
$("<span>").html(v.Id)
]));
});
//on click image, i am calling this method
function cloneImgInSlide(img_src) {
this.disabled = true;
$('#error').text('');
google.script.run.imgInsert(img_src);
}
Code.js (issue in this script)
function imgInsert(src){
var slide = SlidesApp.getActivePresentation().getSlides()[0];
var position = {left: 0, top: 0};
var size = {width: 300, height: 100};
//seems error here after this line
var blob = Utilities.newBlob(src, 'image/png', 'MyImageName');
slide.insertImage(blob, position.left, position.top, size.width, size.height);
}