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
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.
@dstufft any news regarding this?
again any news on this? I can't find examples of uploading images as bytes.
Most helpful comment
@dstufft any news regarding this?