title: Saving 'float' numpy images
body: <p>Here is the code I am currently using:</p>
  
  <pre><code>from PIL import Image
  import numpy as np
  
  def save_np_img(np_img, path, name):
      """
      To save the image.
      :param np_img: numpy_array type image
      :param path: string type of the existing path where to save the image
      :param name: string type that includes the format (ex:"bob.png")
      :return: numpy array
      """
  
      assert isinstance(path, str), 'Path of wrong type! (Must be String)'
      assert isinstance(name, str), 'Name of wrong type! (Must be String)'
  
      im = Image.fromarray(np_img)
      im.save(path + name)
  
      return np_img
  </code></pre>
  
  <p>I would like to be able to save images which contain <code>float</code> values, just like I can currently save <code>int</code> valued-images.</p>
  
  <p>I get a <code>TypeError</code> message when I try to save my images which have been transformed through <code>np.divide(img, 255.)</code>, and thus when trying to save numpy_arrays which contain floats.</p>
  
  <p>(You can suggest other librairies, too.)</p>
  
  <p><strong>NOTE:</strong> The values, when not integers between 0 and 255, are floats between 0 and 1. It is crucial for me to remain as lossless as possible. My initial thought was that I could simply use <code>np.multiply(img, 255)</code> but I wasn't sure if that would lose some precision (nor if it would return integers, actually).</p>
  
  <p><strong>EDIT:</strong> Basically, is <a href="https://stackoverflow.com/a/47292141/9768291">this</a> method a lossless convertion? That is, if I had a numpy_array of <code>ints</code>, divided it by <code>255.</code>, and then reconverted into <code>ints</code>, am I losing information? If so, how to avoid that?</p>