Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instagram Square photos API

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

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.

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

like image 729
Pedro Casado Avatar asked Aug 27 '15 23:08

Pedro Casado


1 Answers

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.

Steps:

  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.

enter image description here

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.

Related Blog Post: API migration for landscape and portrait formats

Previous Answer (Deprecated, do not use unless you want BOTH square and non-square versions, still hacky :) )

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.

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.

Let's take an example and walk through it.

See this one photo of Taylor Swift uploaded by 1 of the user's mentioned in IG's blog post / press release -- @johnbenett

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

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

enter image description here

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
    }

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

enter image description here

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

enter image description here

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

enter image description here

So How do you get the original image for a photo uploaded as a landscape or portrait?

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.

Keeping the same example above:

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

and it looks like this.

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

and it looks like this.

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

and it looks like this.

enter image description here

Hope this helps.

like image 155
Shiva Avatar answered Nov 11 '22 14:11

Shiva