javascript - Unsplash Api 下载特定大小的图像
问题描述
当调用 Unsplash API 时https://api.unsplash.com/photos/?client_id=#{dummy_client_id}
,它会返回以下格式的 JSON
[
{
"id": "kmTq5GU6c-0",
"created_at": "2019-05-27T14:07:14-04:00",
"updated_at": "2020-08-21T01:25:29-04:00",
"promoted_at": null,
"width": 5472,
"height": 3648,
"color": "#FFFFFF",
"description": null,
"alt_description": "man riding black motorcycle",
"urls": {
"raw": "https://images.unsplash.com/photo-1558980394-da1f85d3b540?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEzMDkxNX0",
"full": "https://images.unsplash.com/photo-1558980394-da1f85d3b540?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjEzMDkxNX0",
"regular": "https://images.unsplash.com/photo-1558980394-da1f85d3b540?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjEzMDkxNX0",
"small": "https://images.unsplash.com/photo-1558980394-da1f85d3b540?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjEzMDkxNX0",
"thumb": "https://images.unsplash.com/photo-1558980394-da1f85d3b540?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&ixid=eyJhcHBfaWQiOjEzMDkxNX0"
},
"links": {
"self": "https://api.unsplash.com/photos/kmTq5GU6c-0",
"html": "https://unsplash.com/photos/kmTq5GU6c-0",
"download": "https://unsplash.com/photos/kmTq5GU6c-0/download",
"download_location": "https://api.unsplash.com/photos/kmTq5GU6c-0/download"
},
"categories": [
],
"likes": 409,
"liked_by_user": false,
"current_user_collections": [
],
"sponsorship": {
},
"user": {
}
}
]
我需要下载图像,并且 unsplash 指南指出您需要使用links['download']
来下载图像。下载的图像总是大于 4MB。
如何下载较小尺寸/宽度/高度的图像。?
解决方案
推荐阅读
- ios - 如何摆脱出现在 Share 上的应用程序图标?
- r - r:获取只有 NaN 值的列
- c - 具有多个参数的 kvm 超级调用
- javascript - 如何在本机博览会中深度链接到特定屏幕
- graph - 如何将 (x, y) 映射到一个值?
- mysql - 在 mySQL phpMyAdmin 中创建表后如何查看 Create Table SQL 命令
- python - 如何在子类中使用父类的属性?
- flutter - 当新值返回时,FutureBuilder 已经构建
- python - 添加一列中的所有行并将其显示在文件末尾
- javascript - 如何从 html 到 php 的表单中获取图像类型(不是文件类型)数据?