Skip to content

Commit

Permalink
Merge pull request #22 from camicroscope/develop
Browse files Browse the repository at this point in the history
For 3.6.2
  • Loading branch information
birm authored Mar 29, 2020
2 parents 1eb36af + 5dcb7f9 commit 74aa4aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
FROM python:3-stretch

WORKDIR /var/www

RUN apt-get update
RUN apt-get -q update --fix-missing
RUN apt-get -q install -y openslide-tools python-openslide vim
RUN apt-get -q install -y libvips libvips-dev

RUN pip install pyvips
RUN pip install flask
RUN pip install gunicorn
RUN pip install greenlet
Expand Down
13 changes: 12 additions & 1 deletion SlideServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
import string
import sys
import pyvips

import flask
import flask_cors
Expand Down Expand Up @@ -48,6 +49,16 @@ def getThumbnail(filename, size=50):
except BaseException as e:
return {"type": "Openslide", "error": str(e)}

@app.route('/slide/<filename>/pyramid/<dest>', methods=['POST'])
def makePyramid(filename, dest):
try:
filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
destpath = os.path.join(app.config['UPLOAD_FOLDER'], dest)
pyvips.Image.new_from_file(filepath, access='sequential').tiffsave(destpath, tile=True, compression="lzw", tile_width=256, tile_height=256, pyramid=True, bigtiff=True, xres=0.254, yres=0.254)
return flask.Response(json.dumps({"status": "OK"}), status=200)
except BaseException as e:
return flask.Response(json.dumps({"type": "pyvips", "error": str(e)}), status=500)


# routes

Expand Down Expand Up @@ -110,7 +121,7 @@ def finish_upload(token):
else:
return flask.Response(json.dumps({"error": "Token Not Recognised"}), status=400)
else:
return flask.Response(json.dumps({"error": "Invalid filename"}), status=400)
return flask.Response(json.dumps({"error": "File with name '" + filename + "' already exists"}), status=400)

else:
return flask.Response(json.dumps({"error": "Invalid filename"}), status=400)
Expand Down

0 comments on commit 74aa4aa

Please sign in to comment.