title: Unable to convert an image from PNG TO JPG using PIL (Python Image Library)
body: <p>I use weasyprint library in python to convert an HTML template to png. Then I am trying to convert the png image to jpg using a python library named PIL(PILLOW). </p>
  
  <p><strong><em>The PNG IMAGE</em></strong>  is given below.
  <a href="https://i.stack.imgur.com/UCLgy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UCLgy.png" alt="enter image description here"></a></p>
  
  <p>But the image obtained after conversion using PIL is not what I was expecting. The colors are lost and only some components of the image are visible.</p>
  
  <pre><code>        from PIL import Image
          img = Image.open(file_path)
          rgb_im = img.convert('RGB')
  
          jpg_img_path = os.path.splitext(file_path)[0]
          jpg_img_path += '.jpg'
          rgb_im.save(jpg_img_path)
  </code></pre>
  
  <p>When I tried to use an online editor, they have provided me the perfect image from the png. <strong>Below is the jpg image obtained from the online converter</strong>.
  <a href="https://i.stack.imgur.com/Lr24a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lr24a.png" alt="enter image description here"></a></p>
  
  <p>And the Image when I have used <strong>PIL</strong>.
  <a href="https://i.stack.imgur.com/Tj6nD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tj6nD.jpg" alt="enter image description here"></a></p>