python - 如何指定谷歌幻灯片 API PNG 导出的图像大小?
问题描述
我能够成功运行下面的代码来生成一个带有我的谷歌幻灯片图像的 URL,但是当我尝试指定 thumbnailProperties 时,它说:“得到了一个意外的关键字参数“thumbnailProperties””。我遵循了这个文档:https ://developers.google.com/slides/api/reference/rest/v1/presentations.pages/getThumbnail?hl=es
关于我需要改变什么的任何想法?
service = build('slides', 'v1', credentials=creds)
img = service.presentations().pages().getThumbnail(
presentationId=PRESENTATION_ID,
pageObjectId='gd7f6eed13a_1_17',
# thumbnailProperties = {'thumbnailSize': 'LARGE'}
).execute()
解决方案
在这种情况下,请进行如下修改。
修改后的脚本:
service = build('slides', 'v1', credentials=creds)
img = service.presentations().pages().getThumbnail(
presentationId=PRESENTATION_ID,
pageObjectId='gd7f6eed13a_1_17',
thumbnailProperties_thumbnailSize='LARGE' # Modified
).execute()
由此,得到以下结果。当您要检索缩略图图像时,请从以下下载contentUrl
。在这种情况下,不需要使用访问令牌。
{
'height': 900,
'width': 1600,
'contentUrl': 'https://lh3.googleusercontent.com/###=s1600'
}
参考:
推荐阅读
- python - 如何更正包含空格的 DataFrame 标头。
- c# - 在 selenium webdriver 测试 C# 上添加暂停/播放按钮
- javascript - 如何更改脚本以使其适合下拉列表?
- laravel - Laravel:需要动态验证规则(从配置文件或设置中读取)
- reactjs - Grunt-webpack:如何在没有构建服务器访问权限的情况下强制生产模式?
- javascript - 在 webview Android 中打开 url
- apache-spark - Scala Spark:计算分组的 AUC
- android - java.lang.IndexOutOfBoundsException:索引:1,大小:0
- java - 使用java替换MS word Templete(Docx)中的文本
- camera-calibration - 相机校准原理点等于零