def upload(): if request.files['image']: # 画像として読み込み stream = request.files['image'].stream img_array = np.asarray(bytearray(stream.read()), dtype=np.uint8) img = cv2.imdecode(img_array, 1) # 変換 img1, img2, img3 = canny(img) #変更した # 保存 dt_now = datetime.now().strftime("%Y_%m_%d%_H_%M_%S_") + random_str(5) save_path = os.path.join(SAVE_DIR, dt_now + ".png") cv2.imwrite(save_path, img1) dt_now = datetime.now().strftime("%Y_%m_%d%_H_%M_%S_") + random_str( 5) #追加した save_path = os.path.join(SAVE_DIR, dt_now + ".png") cv2.imwrite(save_path, img2) dt_now = datetime.now().strftime("%Y_%m_%d%_H_%M_%S_") + random_str( 5) #追加した save_path = os.path.join(SAVE_DIR, dt_now + ".png") cv2.imwrite(save_path, img3) print("save", save_path) return redirect('/')
def upload(): if request.files['image']: # 画像として読み込み stream = request.files['image'].stream print(".....................") print(request.files['image']) img_array = np.asarray(bytearray(stream.read()), dtype=np.uint8) img = cv2.imdecode(img_array, 1) # 変換 res = request.form['value'] if res == "hoge": img = canny(img) elif res == "foo": img = anime_filter(img) elif res == "submit": img = make_contour_image(img) # 保存 dt_now = datetime.now().strftime("%Y_%m_%d%_H_%M_%S_") + random_str(5) save_path = os.path.join(SAVE_DIR, dt_now + ".png") cv2.imwrite(save_path, img) print("save", save_path) return redirect('/')