title: Array to image with colour map
body: <p>I have some data in a 2048x2048 array that I want to convert to an image. </p>
  
  <pre><code>import numpy as np
  from PIL import Image    
  
  path = 'E:\\petra_2018_backup\\final\\raw\data\zn_2_run\\'
  file = 'Zn_2_Pos1-01537.tif'   
  
  im = Image.open(path+file)
  
  a = np.array(im)
  
  img = Image.frombytes('CMYK', (2048, 2048), a) # pass in the bytestring
  img.save('pic.pdf')
  img.show()
  </code></pre>
  
  <p>This result is quite dark and also has a mixture of green and blue colours. I should mention that the attached picture is a screendump of the result as the result picture is to large to attach. <a href="https://i.stack.imgur.com/jnyj7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jnyj7.png" alt="Visualisation of the &#39;a&#39; array"></a></p>
  
  <p>It would also be usefull if people can advice on a way to compress the resulting image. </p>