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

Image thumbnail retrieval implemented #54

Merged
merged 4 commits into from
Jul 12, 2021
Merged

Conversation

OmarMuhammedAli
Copy link
Contributor

Related Issue(s) #17

Proposed Changes

  • Create image_thumbnail driver function.
  • Create get_imgae_thumbnail controller to hold business logic
  • Create InvalidImageResolution to handle unsupported input resolution exceptions
  • Create InvalidImageKey to handle invalid input image ID/key exceptions.

Example Usage

        >>> import mapillary as mly
        >>> mly.set_access_token('MLY|XXX')
        >>> mly.image_thumbnail(
        ...     image_id='IMAGE_ID_HERE', resolution='DESIRED_RESOLUTION'
        ... )

@OmarMuhammedAli OmarMuhammedAli added feature A feature request for the SDK requirements A requirement from the PRD labels Jul 11, 2021
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 11, 2021
@OmarMuhammedAli OmarMuhammedAli linked an issue Jul 11, 2021 that may be closed by this pull request
Copy link
Contributor

@Rubix982 Rubix982 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some typos. Other than that, it looks fantastic!

Approving this PR. For the typos, it's not really a big deal. You can make a commit and self merge the branch if you like, or just leave it, I can solve it in my coming PR as well.

Great job. :D

@Rubix982
Copy link
Contributor

Awesome! Merging.

@Rubix982 Rubix982 merged commit 52e4d7d into main Jul 12, 2021
@Rubix982 Rubix982 deleted the Omar-Retrieve-Image-Thumbnail branch July 12, 2021 07:53
def __str__(self) -> str:
return f"""An exception occured, "{self._resolution}" is not a supported image size

Hint: Supported image sizes are: 256, 1024, and 2048
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OmarMuhammedAli will this be exposed to the user? Would be helpful to provide the hint in case they otherwise do not know, so if they enter 320 it can mention the hint in the error message maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbeddow Yes, this hint is exposed to the user. The controller first checks for the given resolution, and if it's not one of the supported ones, it doesn't go on with requesting the thumbnail from the API, and it raises an exception that shows the error message alongside the hint.


:param size: Option for the thumbnail size, ranging from 320 to 2048 width
:type size: int
:param resolution: Option for the thumbnail size, with available resolutions:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should default to 1024 if it is unspecified

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's already implemented. I'll update the docstring to reflect that as well!

@OmarMuhammedAli OmarMuhammedAli self-assigned this Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. feature A feature request for the SDK requirements A requirement from the PRD
Projects
MLH Fellowship
Awaiting triage
Development

Successfully merging this pull request may close these issues.

[Requirements] 6. Get Image Thumbnail
4 participants