Dmitry
Dmitry

Reputation: 477

instagram api return not square photos with white lines

I posted not square photo in instagram https://instagram.com/p/7M7aBoNTcM/

By instagram api using https_//api.instagram.com/v1/media/1061415553965831926_2141618404?access_token=Token tried to get all photos and I have for that image the next standard_resolution url: https://scontent.cdninstagram.com/hphotos-xfa1//t51.2885-15//s640x640//sh0.08//e35//11821940_708988202567623_81870409_n.jpg

There are not param for cropping, but I got my image with white lines at the top and at the bottom of image.

Why on the instagram's web site my image as I sent(rectangular), but api returns square with white lines?

How I can post not square pictures for getting them without white lines?

Upvotes: 14

Views: 6972

Answers (1)

Shiva
Shiva

Reputation: 20935

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. Don't read unless you want box square and landscape / portrait versions at the same time)

As far as I can tell, Instagram has not updated their API to return the original images in various sizes for the new Landscape / Portrait upload feature they rolled out recently.

There is a -- for lack of a better word - "workaround" that you can use to get the original uncropped landscape / portrait images from the square images returned by the api for your landscape / portrait photo.

Here's how.

Take the Thumbnail image URL returned by the API. In your case, the URL returned is https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s150x150/e35/c257.0.565.565/11375403_666004300168456_93194657_n.jpg

enter image description here

If you remove the last url segment before the image name, i.e. /c257.0.565.565 you will get the url for the landscape thumbnail. (see below)

enter image description here

Here's how you get the other 2 sizes in their original aspect ratio.

Now using this new url that has the last url segment removed,

  • if you replace Thumbnail Returned by API (cropped / with white borders) s150x150 with s320x320 you will be the low resolution landscape image url and
  • if you replace Thumbnail Returned by API (cropped / with white borders) s150x150 with s640x640 you will get the standard resolution landscape image.

You can programatically do all this after getting the thumbnail url from the API.

Like I said before, this is a workaround until Instagram officially updates their API and exposes these additional images.

https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s150x150/e35/c257.0.565.565/11375403_666004300168456_93194657_n.jpg

Thumbnail Landscape (uncropped)

https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s150x150/e35/11375403_666004300168456_93194657_n.jpg

Thumbnail Landscape uncropped

Low Resolution Landscape (uncropped)

https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s320x320/e35/11375403_666004300168456_93194657_n.jpg [Low Resolution landscape uncropped2

Standard Resolution Landscape (uncropped)

https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s640x640/e35/11375403_666004300168456_93194657_n.jpg

Standard Resolution Landscape

Upvotes: 33

Related Questions