Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add an image to a google slide? #285

Unanswered
raybell-md asked this question in Q&A
Discussion options

Is their an API for adding images to google slides? From local or google drive?

You must be logged in to vote

Replies: 2 comments 4 replies

Comment options

gws schema slides.CreateImageRequest but wants to use a public url

You must be logged in to vote
4 replies
Comment options

Yeah this is a limitation of the API. It might work with a base64 data URI.

Comment options

Was worth a shot

I tried using a base64 data:image/svg+xml;base64,... URI for the createImage request, but unfortunately, the Google Slides API rejected it with the
following error:
1 {
2 "error": {
3 "code": 400,
4 "message": "Invalid requests[0].createImage: The URL is invalid.",
5 "reason": "unknown"
6 }
7 }
This confirms that the Slides API strictly requires a valid, publicly accessible http or https URL and doesn't support embedding images directly via
base64 data URIs.

Comment options

I'll need to know more about the source location to help further. Is it in drive? I think slides makes a copy of the image so there are some tricks from the urls that are available from other Workspace apps using short-term urls with tokens in them.

Comment options

No was a local file. I thought that would be easier to test before trying a Google Drive file.

I just saved https://upload.wikimedia.org/wikipedia/commons/2/2f/Google_2015_logo.svg to my local machine.

I'm pretending this one isn't Public by saving it to my local machine

Comment options

Yeah, there's a way to do this - it's in the Slides API, but it's not super obvious from the CLI docs. You want the slides.CreateImageRequest method. For local files, you need to upload them to Drive first via the Drive API, then reference the Drive file ID in the image request. For public URLs, you can skip the upload and just pass the URL directly in the imageProperties.contentUrl field. I ran into this last year when automating slide generation - the trick is that the CLI doesn't expose a "from local file" shortcut, so you have to stage it in Drive first. Something like: upload with gdrive upload --name foo.png, grab the ID, then call gws slides create-image --object-id=... --image-id=... --url="https://drive.google.com/uc?id=FILE_ID". If you're doing this often, wrap it in a script. Public URLs are easier - just use the direct link in the image request. Not certain if the CLI

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /