diff --git a/week5/app.py b/week5/app.py index 29d07d1..724bbd4 100644 --- a/week5/app.py +++ b/week5/app.py @@ -65,3 +65,31 @@ def upload_file(): # f = request.files['the_file'] # f.save('/var/www/uploads/uploaded_file.txt') +#to refer backto zoomreplace.html +@app.route('/image/static/img/') +def zoomedimage(imgpath): + print (imgpath) + return render_template("zoomreplace.html", image=imgpath) + +@app.route('/upload2/', methods=['POST']) +def upload2_file(image): + if request.method == 'POST': + file = request.files['tile'] + + if file and allowed_file(file.filename): + filename, fileextension = os.path.splitext(file.filename) + overwrite = image #00.png + + input_file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename + fileextension) + overwritten_file_path = os.path.join(app.config['UPLOAD_FOLDER'], overwrite) + + print("[input file path]:", input_file_path) + print("[overwritten file path]:", overwritten_file_path) + + if 'png' not in fileextension: + print("--- convert uploaded image to png") + cmd = f"convert { input_file_path } { overwritten_file_path }" + os.system(cmd) + + file.save(overwritten_file_path) + return redirect("/") diff --git a/week5/templates/mosaic.html b/week5/templates/mosaic.html index c1e74c5..b3b6069 100644 --- a/week5/templates/mosaic.html +++ b/week5/templates/mosaic.html @@ -9,6 +9,8 @@ width: 10%; margin: 0; padding: 0; + object-fit: cover; + height: 14%; } img:hover{ filter: invert(1); @@ -16,7 +18,7 @@ - {% for image in images %}{% endfor %} + {% for image in images %}{% endfor %}
diff --git a/week5/templates/zoomreplace.html b/week5/templates/zoomreplace.html new file mode 100644 index 0000000..2b5a3b2 --- /dev/null +++ b/week5/templates/zoomreplace.html @@ -0,0 +1,13 @@ + + + + + + + + + +
+ +