Instagram Square照片API [英] Instagram Square photos API

查看:83
本文介绍了Instagram Square照片API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Instagram会提供任何通过API捕获人像/风景的方法吗? API文档看起来没有任何变化.

Will Instagram provide any way to grab the portrait/landscape through the API ? API docs looks untouched.

到目前为止,它们仍然返回人像图像的正方形大小,但是api文档没有提供任何获取原始图像的方法.

As of now, they still returns the square sizes for the portrait images, but the api documentation doesn't provide any way to get the original image.

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

Will they keep returning the square images? Do Instagram have any comments about this?

推荐答案

9月. 2015年4月4日更新:

截至2015年9月3日, instagram现在,如果您在API客户端中更新了新的设置,则允许API客户端以其原始纵横比获取图像(即,对于风景",肖像"为矩形),并且不会裁剪它们.

Sept. 4th 2015 Update:

As of Sept. 3rd 2015, instagram now allows API clients to get the images in their original aspect ratio (i.e. rectangular for Landscapes, Portraits) and will not crop them, if you updated a new setting in the API Client.

  1. https://instagram.com/developer/
  2. 上登录到客户端应用程序设置>
  3. 点击顶部导航菜单上的管理客户.
  4. 找到您的API客户端,然后点击编辑.
  5. 点击API客户端应用程序的迁移标签,然后选中非方形媒体"框.
  6. 点击更新客户端.
  1. Login to into your client application settings on https://instagram.com/developer/
  2. Click Manage Clients on top nav menu.
  3. Locate your API Client, and click Edit.
  4. Click the Migrations Tab for your API Client application, and check the box that says "Non square media".
  5. Click Update Client.

就是这样!现在,当您从API端点获取图像时,上传的肖像,风景将不会被裁剪为正方形图像,并且将返回原始图像.

That's it! Now when you get the images from the API endpoints, the portraits, landscapes that were uploaded will not be cropped to square images, and the originals will be returned.

相关博客文章:针对横向和纵向格式的API迁移

是的,该API看起来没有被改动,但是我发现了一种破解方法,可以获取风景"和肖像"的原始图像.您必须以编程方式删除images数组中返回的一部分网址.

Yes, the API looks untouched, but I found a hack to get to the original images for Landscapes and Portraits. You have to programatically remove a section of the urls returned in the images array.

请参阅下文-来自我的回答此处的摘录.

See below -- snippet from my answer here.

API仍返回图像的正方形版本,即使是以人像"或风景"形式上传的图像也是如此.如果您还想要原始的风景/人像图像,则必须做一些修改(以下详细信息),直到他们在其API响应中解决该问题.

The API is still returning the square versions for images, even the ones that are uploaded as Portraits or Landscapes. If you want the original landscape / portrait images also, you have to do a little hack -- details below -- until they address it in their API response.

请参阅由 IG的博客文章/新闻发布- @johnbenett

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

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

This is the original uploaded photo - Portrait 512 px x 640 px

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

And here's what the Instagram API returns, for the various images (including thumbnail) for the above portrait image.

  "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正方形,并且看起来像这样.

So the standard resolution image returned by the API for this Portrait image is 640 px square and looks like this.

,API对此肖像图像返回的低分辨率图像为 320 px正方形,并且看起来像这样.

and the low resolution image returned by the API for this Portrait image is 320 px square and looks like this.

最后但并非最不重要的一点是,API为该肖像图像返回的缩略图图像为 150 px正方形,并且看起来像这样.

and last but not least, the thumbnail image returned by the API for this Portrait image is 150 px square and looks like this.

由于该API到目前为止仅返回1组图像,但是该网站能够显示原始的长宽比图像,因此我进行了一些挖掘,并意识到,如果您从URL中删除了最后一个但只有1个部分方形图片网址(在此示例中,删除/c0.135.1080.1080),您将获得原始长宽比大小(且未裁剪)的风景肖像图像.

Since the API returns only 1 set of images as of now, but the site is able to show the original aspect ratio images, I did some digging around, and realized that if you remove the last but 1 section of the url from the square image urls (in this example, remove /c0.135.1080.1080 ) you get to the original aspect ratio sized (and uncropped) landscape, portrait images.

保留上面的相同示例:

标准分辨率人像图像(512像素x 640像素)URL: https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s640x640/sh0.08/e35/11909195_1715998838621946_791786043_n.jpg

它看起来像这样.

低分辨率人像图像(256像素x 320像素)URL: https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s320x320/e35/11909195_1715998838621946_791786043_n.jpg

它看起来像这样.

缩略图肖像图片(120 px x 150 px)URL: https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s150x150/e35/11909195_1715998838621946_791786043_n.jpg

它看起来像这样.

希望这会有所帮助.

这篇关于Instagram Square照片API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆