I am trying to upload JPG or PNG images stored in the local file system to Amazon Rekognition on the command line using aws-cli/1.11.175. Images stored in S3 work perfectly fine, but I can't figure out how the CLI call should look like, if the file is stored locally:
# aws rekognition detect-labels --image '???'
The documentation suggests --image "Bytes='...'"
and 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
I tried things like this:
# IMAGE=$(base64 --wrap=0 image.jpg)
# aws rekognition detect-labels --image "Bytes='${IMAGE}'"
# base64 --wrap=0 image.png > image.png.b64
# aws rekognition detect-labels --image "Bytes='file:///image.png.b64'"
Can someone provide an example, how to pass an image stored in the file system to Rekognition, without the need to copy it to an S3 bucket first? How should the --image
option look like?
This is a known issue and has been reported in October 2017:
https://github.com/aws/aws-cli/issues/2931
It's currently marked as a possible enhancement (as of May 2018).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With