title: converting .png images to base64
body: <p>I am trying to encode <em>.png</em> images to base64 so people don't need to have my pictures/change pictures to view it.</p>
  
  <p>I have searched a lot and tried many things, my last attempt got me this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "random.py", line 100, in &lt;module&gt;
      convert(r"C:\Users\simon\Desktop\pictures\pizza_pics\meat_lovers.png")
    File "random.py", line 91, in convert
      data = f.read()
    File "C:\Users\simon\AppData\Local\Programs\Python\Python36-32\lib\encodings\c  p1252.py", line 23, in decode
      return codecs.charmap_decode(input,self.errors,decoding_table)[0]
  UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 30: chara  cter maps to &lt;undefined&gt;
  </code></pre>
  
  <p>I looked into what 0x8d is but found nothing that worked or that I really understood.</p>
  
  <p>This is my code:</p>
  
  <pre><code>#encodes the images from .jpg or .png files to base64 string(lets others view the image)
  def convert(image):
      img = open(image)
      data = img.read()
  
      string = base64.b64encode(data)
      convert = base64.b64encode(string)
  
      img = Image.open(r"C:\Users\simon\Desktop\pictures\pizza_pics\meat_lovers.png", "UTF-8")
      img.write(convert)
  
  if __name__ == "__main__":
      convert(r"C:\Users\simon\Desktop\pictures\pizza_pics\meat_lovers.png")
  
  #shows the image
  img.thumbnail((350, 200), Image.ANTIALIAS)
  photo = ImageTk.PhotoImage(image = img)
  label_image = tk.Label(image = photo)
  label_image.grid(column=0, row=2, padx=(5, 95))
  </code></pre>