如何指定google幻灯片API PNG导出的图像大小?

2024-10-01 13:24:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我成功地运行了下面的代码,生成了一个带有谷歌幻灯片图像的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()

Tags: 代码文档https图像url参数service关键字
1条回答
网友
1楼 · 发布于 2024-10-01 13:24:16

在这种情况下,请修改如下

修改的脚本:

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'
}

参考资料:

相关问题 更多 >