extract detail from pdf
This commit is contained in:
parent
fd34ba305c
commit
5bd561e64f
3 changed files with 75 additions and 5 deletions
|
|
@ -93,6 +93,24 @@ class EpubHandler(OMLHandler):
|
|||
self.set_header('Content-Type', content_type)
|
||||
self.write(z.read(filename))
|
||||
|
||||
class CropHandler(OMLHandler):
|
||||
|
||||
def get(self, id, page, left, top, right, bottom):
|
||||
from media.pdf import crop
|
||||
with db.session():
|
||||
item = Item.get(id)
|
||||
path = item.get_path()
|
||||
print(path, page, left, top, right, bottom)
|
||||
data = crop(path, page, left, top, right, bottom)
|
||||
if data:
|
||||
self.set_header('Content-Type', 'image/jpeg')
|
||||
self.set_header('Content-Length', str(len(data)))
|
||||
self.write(data)
|
||||
return
|
||||
self.set_status(404)
|
||||
return
|
||||
|
||||
|
||||
def serve_static(handler, path, mimetype, include_body=True, disposition=None):
|
||||
handler.set_header('Content-Type', mimetype)
|
||||
size = os.stat(path).st_size
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue