How can Pillow open uploaded image file from StringIO directly?
<p>User upload a image file by the Form, I don't want to save original uploaded image file to disk, and resize image by Pillow opening image from disk.  </p>

<p>I want to resize this image file in memory first, then save the resized image file to disk. so I import StringIO as buffer, but it does't work with Pillow. </p>

<p>Here is the code:  </p>

<p>Python3.4, Flask==0.10.1, Pillow==3.4.2</p>

<h1>forms.py</h1>

<pre><code>class Form():
    img = FileField()
    submit = SubmitField()
</code></pre>

<h1>views.py</h1>

<pre><code>from io import StringIO
from PIL import Image
from .forms import Form

@app.route('/upload_img', methods=['GET', 'POST'])
def upload_img():
    form = Form()
    im = Image.open(StringIO(form.img.data.read())

    pass
</code></pre>

<hr>

<blockquote>
  <p>TypeError: initial_value must be str or None, not bytes</p>
</blockquote>