maxurl
maxurl copied to clipboard
instagram.com prevent parse_image from processing images that are larger than the original
The parse_image
method currently looks like this:
var parse_image = function(img_i, img) {
var candidates = img.image_versions2.candidates;
var maxsize = 0;
var maxobj = null;
// ... rest of function
};
Sometimes instagram returns image candidates with resolution properties that are greater than the original: https://www.instagram.com/p/CJPzaGkrSPy/ (first image became 720x720, whilst it actually is 720x900)
To prevent maxurl from attempting to get images that are greater than the original, and therefore not exist, filter them out before finding out the best candidate that was returned by instagram's api.
var parse_image = function(img_i, img) {
var candidates = img.image_versions2.candidates;
var maxheight = img.original_height;
var maxwidth = img.original_width;
candidates = candidates.filter(c => c.width <= maxwidth && c.height <= maxheight);
var maxsize = 0;
var maxobj = null;
// ... rest of function
};
Perhaps should also be tested about any impact on video, if there is any.