Value Error: Too many dimensions: 3 > 2
<p>I've tried to resize image with scipy and everything seems to work fine until I try to save the image. When I try to save image I get error that you can see in title. Full traceback is available below. </p>

<pre><code>import numpy as np
import scipy.misc
from PIL import Image

image_path = "img0.jpg"


def load_image(img_path):
    img = Image.open(img_path)
    img.load()
    data = np.asarray(img, dtype="int32")
    return data


def save_image(npdata, outfilename):
    img = Image.fromarray(np.asarray(np.clip(npdata, 0, 255), dtype="uint8"), "L")
    img.save(outfilename)

array_image = load_image(image_path)

array_resized_image = scipy.misc.imresize(array_image, (320, 240), interp='nearest', mode=None)

save_image(array_resized_image, "i1.jpg")
</code></pre>

<p>Full traceback of the error:</p>

<pre><code>Traceback (most recent call last):
  File "D:/Python/Playground/resize image with scipy.py", line 26, in &lt;module&gt;
    save_image(array_resized_image, "i1.jpg")
  File "D:/Python/Playground/resize image with scipy.py", line 16, in save_image
    img = Image.fromarray(np.asarray(np.clip(npdata, 0, 255), dtype="uint8"), "L")
  File "C:\Anaconda2\lib\site-packages\PIL\Image.py", line 2154, in fromarray
    raise ValueError("Too many dimensions: %d &gt; %d." % (ndim, ndmax))
ValueError: Too many dimensions: 3 &gt; 2.
</code></pre>