Bob
Bob

Reputation: 8714

Instagram API custom image width

I am trying to set custom width for images in Instagram, using Instagram API. I am using hashtag to grab all images related. Can I ask Instagram to serve me custom image sizes? I know there are 3 sizes: thumbnail, low_resolution, standard_resolution. Is that all what I can get? Thanks!

Upvotes: 8

Views: 11760

Answers (5)

speedstyle
speedstyle

Reputation: 141

I know this is an old post, but I thought I should add that there are many more than three (or four) image sizes available. I wrote a short Python script and found the following:

  12    90   200   376   719
  16    96   203   390   720
  24   100   206   403   750
  30   111   224   405   768
  32   112   240   408   800
  34   114   243   417   810
  40   118   256   468   936
  43   120   262   479   959
  48   128   270   480   960
  50   129   279   512  1008
  56   130   280   515  1024
  57   133   285   540  1029
  60   135   288   562  1056
  64   147   306   564  1080
  68   148   319   599  1225
  73   150   320   600  1300
  74   160   332   624  1440
  75   180   338   640  1536
  80   190   350   672  2048
  86   192   360   704

As far as I can tell, everything above 1080 (so 1225, 1300, 1440, 1536, 2048) returns at 1080.

I tested it with a square photo, so I don't know what would be available with different aspect ratios.

Upvotes: 0

Blade1336
Blade1336

Reputation: 71

As the previous posters described, there's no way of Instagram serving images in the exact size you need. They only have three or four default sizes available.

You'll need to implement some kind of middleware that resizes the images for you or use a service like https://tiny.pictures/ (disclaimer: which I am a developer at) to do it for you.

Upvotes: 0

Willster
Willster

Reputation: 2586

Instagram API returns three standard image resolutions. There is an additional undocumented image size that you could also use however, this might be a bit brittle/liable change in the future and it may also be against their terms of service (not sure). I noticed that this image was available when I saw that the Instagram website was serving up higher resolution images- I'm not really sure why Instagram choose not to make this image available.

From the API, you can get these standard image sizes:

thumbnail (150 x 150)

https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s150x150/e15/11821182_168255950173048_11130460_n.jpg

low_resolution (320 x 320)

https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s320x320/e15/11821182_168255950173048_11130460_n.jpg

standard resolution (640 x 640)

https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s640x640/sh0.08/e35/11821182_168255950173048_11130460_n.jpg

Then, by looking at their website, I noticed they served up a larger version of the file at 1080 x 1080:

undocumented large image (1080 x 1080)

https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s1080x1080/e15/11821182_168255950173048_11130460_n.jpg

Upvotes: 14

Metablocks Corp
Metablocks Corp

Reputation: 1645

Simple do a search and replace on _5 (or _6, ie) to get get your desired size (see below):

Image sizes appear to be:

http://distilleryimage7.s3.amazonaws.com/xxxxxxxxx_7.jpg

612px × 612px

http://distilleryimage7.s3.amazonaws.com/xxxxxxxxx_6.jpg

306px × 306px

http://distilleryimage7.s3.amazonaws.com/xxxxxxxxx_5.jpg

150px × 150px

It appears _8,_4,_3 are not valid sizes.

Upvotes: 4

John Hall
John Hall

Reputation: 58

Instagram uses Amazon S3 to save its photo and has a certain naming convention that goes like this:

http://distilleryimage7.s3.amazonaws.com/f4947c1004ca11e2a0c81231380ff428_7.jpg
http://distilleryimage7.s3.amazonaws.com/f4947c1004ca11e2a0c81231380ff428_6.jpg
http://distilleryimage7.s3.amazonaws.com/f4947c1004ca11e2a0c81231380ff428_5.jpg

By simply getting the photo URL via the API and then changing the _7, _6, _5 in the image URL to another value (via a search/replace), you can control the size of the image.

Upvotes: 0

Related Questions