title: how to save an image in python variable and then change it to grayscale?
body: <p>I need to do  image processing for barcode. I know that I can save a picture and then load it in grayscale color_mode, but I dont want to load an image, instead I want to change the color of image into grayscale without saving or without having another image.</p>
  <pre><code>imag=Image.open('barcode.png')
  w, h = imag.size
  region = imag.crop((0, 20, w, h-150))
  region.save(&quot;regions.png&quot;)  #I dont want to save this image 
  img=image.load_img(&quot;regions.png&quot;,color_mode=&quot;grayscale&quot;)  #I want to do this work in a variable i.e. changing the color of image into grayscale without having a need of loading an image
  
  </code></pre>