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

Pass image bytes to Rekognition without S3 not working #2931

Closed
schams-net opened this issue Oct 30, 2017 · 5 comments
Closed

Pass image bytes to Rekognition without S3 not working #2931

schams-net opened this issue Oct 30, 2017 · 5 comments
Assignees
Labels
enhancement feature-request A feature should be added or improved. rekognition

Comments

@schams-net
Copy link

According to the documentation, one can pass image bytes to a Rekognition API operation by using the Bytes property in the --image option:

aws rekognition detect-labels --image "Bytes=blob"

I tried countless combinations, but to no avail. I also understand, that the image should be base64 encoded. However, whatever I try, I end up with the following error message.

An error occurred (InvalidImageFormatException) when calling the DetectLabels
operation: Invalid image encoding

It seems that the aws-cli takes the input "blob" you give it, and base64-encodes it again. The problem is, it doesn't in fact treat the input as a blob. It treats it as a string and tries to interpret it as utf8, so you can't actually pass a blob unless by coincidence you happen to be in possession of a blob that just happens to be comprised of entirely valid utf8 characters. Even if you pass JSON, it still encodes the Bytes value to base64.

As a consequence, the only option is to upload the image to S3 first, and then refer to it by using the S3Object property. However this is not always desired and the lack of "Bytes=blob" support seems to be in contrast to the documentation and build-in help texts.

System/software used:
aws-cli/1.11.175 Python/2.7.13 Linux/4.8.0-2-amd64 botocore/1.7.33

@dstufft
Copy link
Contributor

dstufft commented Oct 31, 2017

This is not currently possible due to the way that the CLI exposes these input. I'm going to file this as an enhancement to this API to allow passing bytes directory to the command. In the mean time you'll need to use the S3 work around.

@killthekitten
Copy link

@dstufft any news regarding this?

@diehlaws diehlaws added feature-request A feature should be added or improved. and removed enhancement labels Jan 4, 2019
@justnance justnance added enhancement and removed feature-request A feature should be added or improved. labels Apr 15, 2019
@joseph-allen
Copy link

again any news on this? I can't find examples of uploading images as bytes.

@kdaily kdaily added the feature-request A feature should be added or improved. label Feb 8, 2021
@tim-finnigan tim-finnigan self-assigned this Nov 10, 2021
@tim-finnigan
Copy link
Contributor

Hi everyone, it looks like this is now an option. Here is the command you can use:
aws rekognition detect-labels --image-bytes fileb://tree.jpg

I tested this and confirmed that it works. For reference this can be found here in the documentation: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/rekognition/detect-labels.html

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature-request A feature should be added or improved. rekognition
Projects
None yet
Development

No branches or pull requests

8 participants