title: Python Face_Recognition with base64 encoded image
body: <p>I'm using <a href="https://pypi.org/project/face-recognition/" rel="nofollow noreferrer">face_recognition</a> package for face recognition</p>
  <p>Input image file is base64 encoded,</p>
  <p>I'm trying to decode the data and</p>
  <pre><code>face_recognition.face_encodings(decodedBase64Data)
  </code></pre>
  <p>And i have face encoded data list to compare.</p>
  <p>The problem is i need to convert the base64 data to image that i can encode using face_encodings.</p>
  <p>I tried with</p>
  <pre><code>decodedData = base64.b64decode(data)
  encodeFace = np.frombuffer(decodedData, np.uint8)
  </code></pre>
  <p>And pass the encodedFace to</p>
  <pre><code>face_recognition.face_encodings(decodedBase64Data)
  </code></pre>
  <p>I get error <code>Unsupported image type, must be 8bit gray or RGB image.</code></p>
  <p>How to convert base64 into image compatible to face_encodings?</p>
  <p><strong>Edit :</strong></p>
  <p>Code attached for reference</p>
  <pre><code>import base64
  import numpy as np
  import json
  import face_recognition as fr
  
  with open('Face_Encoding_Data.json') as f:
      EncodeJsonData = json.load(f)
      personName = list(EncodeJsonData.keys())
      encodedImgList = list(EncodeJsonData.values())
  &quot;&quot;&quot;
  EncodeJsonData = {&quot;name1&quot; : [encoded data 1], &quot;name2&quot; : [encoded data 2]}
  128 byte
  &quot;&quot;&quot;
  base64Data = &quot;&quot;&quot; base64 encoded image with face &quot;&quot;&quot;
  encodeFace = np.frombuffer(base64.b64decode(base64Data), np.uint8)
  
  matches = fr.compare_faces(encodedImgList, encodeFace, tolerance=0.5)
  
  faceDist = fr.face_distance(encodedImgList, encodeFace)
  matchIndex = np.argmin(faceDist)
  
  name = &quot;unknown&quot;
  if matches[matchIndex]:
      name = personName[matchIndex]
  
  print(name)
  </code></pre>