i unable figure out how return image in google apps script. i've gone through lot of documentation , unable find clear.
in php, equivalent function be:
header('content-type: image/gif'); echo "\x47\x49\x46\x38\x37\x61\x1\x0\x1\x0\x80\x0\x0\xfc\x6a\x6c\x0\x0\x0\x2c\x0\x0\x0\x0\x1\x0\x1\x0\x0\x2\x2\x44\x1\x0\x3b";
i've tried functions like:
function doget() { return contentservice.createtextoutput("\x47\x49\x46\x38\x37\x61\x1\x0\x1\x0\x80\x0\x0\xfc\x6a\x6c\x0\x0\x0\x2c\x0\x0\x0\x0\x1\x0\x1\x0\x0\x2\x2\x44\x1\x0\x3b"); } }
but not seem work. want return 1x1 pixel image.
google apps script contentservice supports returning plain text, atom, csv, ical, javascript, json, rss, vcard, , xml content.
it depends on user case, can use htmlservice , data uri scheme embed image:
gs:
function doget(e) { template = htmlservice.createtemplatefromfile('html'); return template.evaluate().setsandboxmode(htmlservice.sandboxmode.iframe); }
html:
<!doctype html> <html> <head> <base target="_top"> </head> <body> <img src="data:image/gif;base64,r0lgodlhaqabaiaaaauebaaaacwaaaaaaqabaaacakqbads="> </body> </html>
also can use html5 , canvas:
<canvas id="mycanvas" width="1" height="1"></canvas>
or javascript create gif
Comments
Post a Comment