Has anyone tried uploading an image of a chart from Google Sheets to Mastodon via Google Apps Scripts?
-
Has anyone tried uploading an image of a chart from Google Sheets to Mastodon via Google Apps Scripts?
I...can't be the only one.
-
Stefan Bohacekreplied to Stefan Bohacek last edited by
I think I'm just not getting the chart image the right way, here's what I tried.
work-in-progress-google-apps-sheets-mastodon.js
GitHub Gist: instantly share code, notes, and snippets.
Gist (gist.github.com)
This is all based on https://stefanbohacek.com/blog/making-a-mastodon-bot-with-google-sheets-and-apps-scripts/. Posting a status works fine, but when I try uploading an image, I get:
"Error processing thumbnail for uploaded media"
-
Negative12DollarBillreplied to Stefan Bohacek last edited by
@stefan
What format is the image you're trying to send? -
Stefan Bohacekreplied to Negative12DollarBill last edited by
@negative12dollarbill I'm not actually too sure.
Here's how I'm trying to pull it out of Google Sheets: https://gist.github.com/stefanbohacek/0874d2c88e666022c4a125182e83658e#file-google-apps-sheets-mastodon-js-L9
-
Negative12DollarBillreplied to Stefan Bohacek last edited by
@stefan
Yeah I noticed that. If there's a method for getting it as a PNG, then clearly getting its raw bytes might not get it as a PNG.Dump the content of `imageData` and see what it looks like?
-
Stefan Bohacekreplied to Negative12DollarBill last edited by
@negative12dollarbill Yep, I tried that, but let me poke around a bit more when I'm back at my computer later tonight. Thank you!
-
Negative12DollarBillreplied to Stefan Bohacek last edited by
@stefan
If it was me I'd try saving it as a temp file PNG and reading it back off disk, I think. Good luck! -
Stefan Bohacekreplied to Negative12DollarBill last edited by
@negative12dollarbill Yeah, that would make things a lot easier. I'll have to look into whether Apps Scripts lets you do that.
Thanks for the tip!
-
Stefan Bohacekreplied to Stefan Bohacek last edited by
Alright, I figured it out! https://stefanbohacek.online/@stefan/113087285806500864