title: Convert BLOB image to PNG, JPG with Python
body: <p>I have several blob images in Oracle, so I read them with python.
  I can correctly read and convert images from a certain table1 with my code, but when changing to  table2 I cannot execute the same code because I get the following error.</p>
  
  <p><code>cannot identify image file &lt;_io.BytesIO object at 0x000000000C4520A0&gt;</code> </p>
  
  <p>This is my code: </p>
  
  <pre><code>import pandas as pd
  import cx_Oracle
  from PIL import Image
  #[connection to database with connecting string `conn`]
  #[query to acces 1 single image]
  result = pd.read_sql(query, conn) #connection to db
  img = result["IMAGE"][0].read()  # reading the first BLOB result 
  pre_img = io.BytesIO(img)
  Image.open(pre_img)
  </code></pre>
  
  <p>This code works well, so the only problem is when I try to read images from table1 . Also at SQL developer I can previsualize the photos from table1, but not with table2. The type of data is BLOB as describe(table) says in Oracle.</p>
  
  <p>value of <code>img</code> can be found <a href="https://textsaver.flap.tv/lists/2z0s" rel="nofollow noreferrer">here</a> </p>
  
  <p><a href="https://i.stack.imgur.com/Tugtm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tugtm.png" alt="sql can&#39;t read the image neither"></a></p>