Finish thumbnail generation and DB optimization

(#93)
This commit is contained in:
Alex Ling
2020-10-24 04:12:36 +00:00
parent 0582b57d60
commit 44f4959477
3 changed files with 101 additions and 14 deletions
+8 -2
View File
@@ -213,11 +213,17 @@ class Entry
img = read_page(1).not_nil!
begin
thumbnail = ImageSize.resize img.data, height: 300
size = ImageSize.get img.data
if size.height > size.width
thumbnail = ImageSize.resize img.data, width: 200
else
thumbnail = ImageSize.resize img.data, height: 300
end
img.data = thumbnail
Storage.default.save_thumbnail @id, img
rescue e
Logger.warn "Failed to generate thumbnail for entry #{@id}. #{e}"
Logger.warn "Failed to generate thumbnail for entry " \
"#{@book.title}/#{@title}. #{e}"
end
img