首页 文章

Instagram Square照片API

提问于
浏览
11

Instagram会提供任何方式来通过API获取肖像/风景吗? API文档看起来没有变化 .

截至目前,他们仍然返回肖像图像的方形大小,但api文档没有提供任何方式来获取原始图像 .

他们会继续返回方形图像吗? Instagram对此有何评论?

1 回答

  • 23

    2015年9月4日更新:

    截至2015年9月3日,instagram now allows API clients to get the images in their original aspect ratio(即风景,肖像的矩形)并且如果您在API客户端中更新了新设置,则不会裁剪它们 .

    步骤:

    • 登录https://instagram.com/developer/上的客户端应用程序设置

    • 单击顶部导航菜单上的 Manage Clients .

    • 找到您的API客户端,然后单击 Edit .

    • 单击API Client应用程序的 Migrations 选项卡,然后选中"Non square media"框 .

    • 单击 Update Client .

    enter image description here

    而已!现在,当您从API endpoints 获取图像时,上传的人像,风景将不会被裁剪为方形图像,并且将返回原始图像 .

    相关博客文章:API migration for landscape and portrait formats

    上一个答案(已弃用,除非你想要两个方形和非方形版本,否则不要使用,仍然是hacky :))

    是的,API看起来没有变化,但是我找到了一个黑客来获取Landscapes和Portraits的原始图像 . 您必须以编程方式删除 images 数组中返回的部分网址 .

    见下文 - 来自my answer here的片段 .

    API仍然返回图像的方形版本,甚至是作为Portraits或Landscapes上传的版本 . 如果你还想要原始的风景/肖像图像,你必须做一些小问题 - 下面的详细信息 - 直到他们在API响应中解决它 .

    让我们举一个例子来看看它 .

    查看Taylor Swift上传的1张照片,其中包括IG's blog post / press release中提到的用户1 - @johnbenett

    https://instagram.com/p/6ZVIHTJLYg/

    这是原始上传的照片 - 肖像 512 px x 640 px

    enter image description here

    以下是Instagram API返回的内容,用于上述肖像图像的各种图像(包括缩略图) .

    "images": {
        "low_resolution": {
          "url": "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s320x320/e35/c0.135.1080.1080/11909195_1715998838621946_791786043_n.jpg",
          "width": 320,
          "height": 320
        },
        "thumbnail": {
          "url": "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s150x150/e35/c0.135.1080.1080/11909195_1715998838621946_791786043_n.jpg",
          "width": 150,
          "height": 150
        },
        "standard_resolution": {
          "url": "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s640x640/sh0.08/e35/c0.135.1080.1080/11909195_1715998838621946_791786043_n.jpg",
          "width": 640,
          "height": 640
        }
    

    因此,此肖像图像的API返回的标准分辨率图像是 640 px square ,看起来像这样 .

    enter image description here

    此肖像图像的API返回的低分辨率图像是 320 px square ,看起来像这样 .

    enter image description here

    最后但并非最不重要的是,API为此肖像图像返回的缩略图图像是 150 px square ,看起来像这样 .

    enter image description here

    那么如何获得作为风景或肖像上传的照片的原始图像?

    由于API现在只返回1组图像,但该网站能够显示原始宽高比图像,我做了一些挖掘,并意识到如果从方形图像中删除网址的最后但1部分url(在此示例中,删除 /c0.135.1080.1080 ),您将获得原始宽高比大小(和未剪切)的横向,纵向图像 .

    保持上面相同的例子:

    Standard Resolution Portrait Image ( 512 px x 640 px ) URL: https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s640x640/sh0.08/e35/11909195_1715998838621946_791786043_n.jpg

    它看起来像这样 .

    enter link description here

    Low Resolution Portrait Image ( 256 px x 320 px ) URL: https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s320x320/e35/11909195_1715998838621946_791786043_n.jpg

    它看起来像这样 .

    enter image description here

    Thumbnail Portrait Image ( 120 px x 150 px ) URL: https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s150x150/e35/11909195_1715998838621946_791786043_n.jpg

    它看起来像这样 .

    enter image description here

    希望这可以帮助 .

相关问题