Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use smallest image from image_versions2 #24

Open
user24 opened this issue Jun 3, 2020 · 0 comments
Open

Use smallest image from image_versions2 #24

user24 opened this issue Jun 3, 2020 · 0 comments

Comments

@user24
Copy link
Contributor

user24 commented Jun 3, 2020

Currently the bot is just picking out the zeroth element:

url = post['image_versions2']['candidates'][0]['url']

But it would be more efficient if we sorted by size and picked the smallest image to send to the detection API.

I've done this in JS (am working on a node version bc I don't know python) but in the meantime if someone wants to port this to python I think this would be an improvement:

const smallestImage = item.image_versions2.candidates.sort((a, b) => a.width * a.height > b.width * b.height).pop();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant