Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
Add loading image from filename.#2778
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -30,22 +30,35 @@ class Image(object): | ||
| :type content: bytes | ||
| :param content: Byte stream of an image. | ||
| :type filename: str | ||
| :param filename: Filename to image. | ||
| :type source_uri: str | ||
| :param source_uri: Google Cloud Storage URI of image. | ||
| :type client: :class:`~google.cloud.vision.client.Client` | ||
| :param client: Instance of Vision client. | ||
| """ | ||
| def __init__(self, client, content=None, source_uri=None): | ||
| def __init__(self, client, content=None, filename=None, source_uri=None): | ||
| sources = [source for source in (content, filename, source_uri) | ||
| if source is not None] | ||
| if len(sources) != 1: | ||
| raise ValueError( | ||
| 'Specify exactly one of "content", "filename", or ' | ||
| '"source_uri".') | ||
| self.client = client | ||
| self._content = None | ||
| self._source = None | ||
| if source_uri: | ||
| self._source = source_uri | ||
| else: | ||
| self._content = _bytes_to_unicode(b64encode(_to_bytes(content))) | ||
| if filename is not None: | ||
| with open(filename, 'rb') as file_obj: | ||
| content = file_obj.read() | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| if content is not None: | ||
| content = _bytes_to_unicode(b64encode(_to_bytes(content))) | ||
| self._content = content | ||
| self._source = source_uri | ||
| def as_dict(self): | ||
| """Generate dictionary structure for request. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -7,6 +7,7 @@ localdeps = | ||
| pip install --quiet --upgrade {toxinidir}/../core | ||
| deps = | ||
| {toxinidir}/../core | ||
| mock | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| pytest | ||
| covercmd = | ||
| py.test --quiet \ | ||
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.