Skip to content

Use smallest image from image_versions2 #24

Open
@user24

Description

@user24

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();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions