title: Getting InvalidImageFormatException as I try pass image to AWS Rekognition
body: <p>I get <code>InvalidImageFormatException</code> as I am trying to pass an image to <code>AWS Rekognition</code>. I make an HTTP request to an <a href="http://www.xsjjys.com/data/out/43/WHDQ-511895361.jpg" rel="nofollow noreferrer">Image URL</a>, download the image and pass the buffer to the aws function.</p>
  
  <p>Here is the code for it:</p>
  
  <pre><code>const AWS = require('aws-sdk');
  const axios = require('axios');
  let rekognition = new AWS.Rekognition({apiVersion: '2016-06-27', region: 'us-east-1'});
  
  let url = 'http://www.xsjjys.com/data/out/43/WHDQ-511895361.jpg'
  
  axios({
      method: 'GET',
      url,
      responseType: 'arraybuffer'
  })
      .then(response =&gt; {
              console.log(response)
              let params = {
                      Image: {
                              Bytes: response.data
                      },
                      Attributes: ['ALL']
              };
  
              rekognition.detectFaces(params, (err, data) =&gt; {
                      if(err) console.log(err);
                      else console.log(JSON.stringify(data));
              });
      })
      .catch(err =&gt; console.log(err));
  </code></pre>
  
  <p>I do not understand what could be the reason for this error. It works for other images but throws an error for some of the images. What could be the reason for this?</p>
  
  <p>Here is the trace for this:</p>
  
  <pre><code>{ InvalidImageFormatException: Invalid image encoding
          at Request.extractError (/home/suhail/nodejs/test/node_modules/aws-sdk/lib/protocol/json.js:48:27)
          at Request.callListeners (/home/suhail/nodejs/test/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
          at Request.emit (/home/suhail/nodejs/test/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
          at Request.emit (/home/suhail/nodejs/test/node_modules/aws-sdk/lib/request.js:683:14)
          at Request.transition (/home/suhail/nodejs/test/node_modules/aws-sdk/lib/request.js:22:10)
          at AcceptorStateMachine.runTo (/home/suhail/nodejs/test/node_modules/aws-sdk/lib/state_machine.js:14:12)
          at /home/suhail/nodejs/test/node_modules/aws-sdk/lib/state_machine.js:26:10
          at Request.&lt;anonymous&gt; (/home/suhail/nodejs/test/node_modules/aws-sdk/lib/request.js:38:9)
          at Request.&lt;anonymous&gt; (/home/suhail/nodejs/test/node_modules/aws-sdk/lib/request.js:685:12)
          at Request.callListeners (/home/suhail/nodejs/test/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
      message: 'Invalid image encoding',
      code: 'InvalidImageFormatException',
      time: 2018-04-03T13:28:43.404Z,
      requestId: 'edd8fccf-3742-11e8-95a3-c58fca411044',
      statusCode: 400,
      retryable: false,
      retryDelay: 55.96279161227613 }
  </code></pre>