File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 1616import os
1717
1818from flask import Flask
19- import scipy .misc
19+ from PIL import Image
20+ import imageio
2021
2122app = Flask (__name__ )
2223
2324
2425@app .route ('/' )
2526def resize ():
26- """Demonstrates using scipy to resize an image."""
27+ """Demonstrates using Pillow to resize an image."""
2728 app_path = os .path .dirname (os .path .realpath (__file__ ))
2829 image_path = os .path .join (app_path , 'assets/google_logo.jpg' )
29- img = scipy .misc .imread (image_path )
30- img_tinted = scipy .misc .imresize (img , (300 , 300 ))
30+ img = Image .fromarray (imageio .imread (image_path ))
31+ img_tinted = img .resize ((300 , 300 ))
32+
3133 output_image_path = os .path .join (
3234 app_path , 'assets/resized_google_logo.jpg' )
3335 # Write the tinted image back to disk
34- scipy . misc . imsave (output_image_path , img_tinted )
36+ imageio . imwrite (output_image_path , img_tinted )
3537 return "Image resized."
3638
3739
Original file line number Diff line number Diff line change 11Flask == 1.1.1
22gunicorn == 20.0.4
3+ imageio == 2.8.0
34numpy == 1.18.2
4- scipy == 1.2.0
55pillow == 7.1.0
6+ scipy == 1.4.1
You can’t perform that action at this time.
0 commit comments