我正在尝试从我的个人Google Photo帐户下载完整图片。
图像本身是用iPhone 6+以2448×3264的分辨率拍摄的,但到目前为止我能拍到的最大尺寸是缩略图尺寸为384x512。
以下是Google Picker API v3返回的数据:
> data.docs[0]
{
id:"6249684261772136370",
mediaKey:"AF1QipPWLtKuyF09rcIQd4UT2tjb1YxkWSypm6PHXfeX",
mimeType:"application/vnd.google-apps.photo",
name:"IMG_5853.JPG",
parentId:"6249684260517294833",
serviceId: "picasa",
thumbnails: (5) [{…}, {…}, {…}, {…}, {…}],
type:"photo",
url:"https://picasaweb.google.com/105232457300095210093/ALBUM_NAME#HASH"
}
以下是我在使用OAuth2
请求access_token时声明的scopes
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/photos",
"https://www.googleapis.com/auth/drive",
"https://picasaweb.google.com/data/"
以下是我发送到“图像元数据”端点的请求,其中gdata版本设置为3:https://picasaweb.google.com/data/entry/api/user/default/albumid/6249684260517294833/photoid/6249684261772136370
然后获取以下XML https://pastebin.com/jgXEqftN,但<content type="image/jpeg" src="..." />
下的图片仍为缩略图。
我知道必须有一种方法可以实现这一点,因为像filestack这样的公司可以下载全尺寸图像。有什么意见/建议吗?
请注意,我知道Google照片和Google驱动器是两种不同的产品。但是,既然您可以通过Google云端硬盘访问Google照片中的图片,也可以使用Picker的文档,明确gives an example使用Google Drive v3 API,我想我会尝试一下这个例子:
curl --header "Authorization: Bearer ya29.GlsABSW1XLQRocTsxsFlGKmVnx3iCwjAxQCFWG-3YH9nM6IYdLyp8x9v4XLglUEMK1XKsgf8SjYzRpbHJa5xDat5M7PcOfJhViOZAa-S6aAGuWKPe98AJ_y2QtH7" https://www.googleapis.com/drive/v3/files/6244822006604119090\?alt\=media
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "File not found: 6244822006604119090.",
"locationType": "parameter",
"location": "fileId"
}
],
"code": 404,
"message": "File not found: 6244822006604119090."
}
}
答案 0 :(得分:1)
这个问题已经解决了,但不是没有挫折感,也没有感觉到为什么没有记录在任何地方。
要获取原始图像,我需要删除任何返回的缩略图网址。例如,给出以下
注意网址中的/s72
。通过将其替换为/s0
,我们将获得未剪切的图像。想要图像宽1024px?通过/s1024
。这是执行此操作的JavaScript代码
thumbnail_url.replace(/\/s\S+?\//g, "/s0/")