question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bytes parameter in rekognition throws "Request has invalid image format" error

See original GitHub issue

Node version: v8.11.3 Npm version: 6.4.1 SDK version: 2.335.0

Bytes parameter not recognizing base64 encoded string “image/png;base64,Qk02EA…” and throwing error “InvalidImageFormatException: Request has invalid image format” when i try to make the request. I also tried with:

  • Buffer
  • Blob
  • Typed Array

They all display the same error. Test case:

let params = {
   Image: {
     Bytes: 'BASE_64_STRING'
   },
};

rekognition.detectFaces(params, function(err, data) {
    if (err) {console.log(err, err.stack)}
    else console.log(JSON.stringify(data);
});

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
srchasecommented, Oct 19, 2018

Can you give an example of how you are setting up the Bytes (or Buffer, Blob, Typed Array)?

This Buffer example should work for you:

const fs = require('fs');
const file = 'foo.jpeg';
const bitmap = fs.readFileSync(file);
const buffer = new Buffer.from(bitmap, 'base64')

let params = {
   Image: {
     Bytes: buffer
   },
};

Could you also try using uploading the same image to the Rekognition Console?

0reactions
lock[bot]commented, Sep 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

error InvalidImageFormatException: Request has invalid ...
This image is a jpeg 250px square and was sent as a valid base64 string (atob tested). Aparently, it meets the requisites presented...
Read more >
Error handling - Amazon Rekognition - AWS Documentation
Describes how to handle client and server errors returned by Amazon DynamoDB operations. ... Message: Request has invalid image format.
Read more >
AWS Rekognition JS SDK Invalid image encoding error-Reactjs
In case someone is doing this on the Node side, I was running into a similar issue when reading in a file in...
Read more >
Error messages - Resource Manager - Google Cloud
badRequest, The API request is invalid or improperly formed. ... The alt parameter value specifies an output format that is not supported for...
Read more >
RekognitionClient | aws-sdk-swift
If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes isn't supported. The image must be formatted as a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found