aboutsummaryrefslogtreecommitdiff
path: root/backend/hist_data/gen_imgs.py
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2022-10-03 23:41:18 +1100
committerTerry Truong <terry06890@gmail.com>2022-10-03 23:41:31 +1100
commit5c0afa3e9a80fdcfa77bfc01b6373121f6ff3c6d (patch)
tree95bada97a649b7459d1ff8e523aac7f979d674eb /backend/hist_data/gen_imgs.py
parent0c6c79084bd0ba331c469b4203627f18eb3b8275 (diff)
Tweak gen_imgs.py output
Diffstat (limited to 'backend/hist_data/gen_imgs.py')
-rwxr-xr-xbackend/hist_data/gen_imgs.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/backend/hist_data/gen_imgs.py b/backend/hist_data/gen_imgs.py
index 0b2f480..817de03 100755
--- a/backend/hist_data/gen_imgs.py
+++ b/backend/hist_data/gen_imgs.py
@@ -13,7 +13,7 @@ to skip.
import os, math, subprocess
import sqlite3, urllib.parse
import signal
-from PIL import Image, UnidentifiedImageError
+from PIL import Image
IMG_DIR = os.path.join('enwiki', 'imgs')
IMG_DB = os.path.join('enwiki', 'img_data.db')
@@ -21,7 +21,7 @@ OUT_DIR = 'img'
DB_FILE = 'data.db'
#
MAX_MINOR_DIM = 200
-MAX_DIM_RATIO = 2
+MAX_DIM_RATIO = 3/2
def genImgs(imgDir: str, imgDb: str, outDir: str, dbFile: str):
""" Converts images and updates db, checking for entries to skip """
@@ -116,8 +116,8 @@ def convertImage(imgPath: str, outPath: str):
try:
with Image.open(imgPath) as image:
width, height = image.size
- except UnidentifiedImageError as e:
- print(f'ERROR: Unable to open/identify {imgPath}: {e}')
+ except Exception as e: # Being more specific runs the risk of ending the program without committing to db
+ print(f'ERROR: Unable to open {imgPath}: {e}')
return False
# Limit output dims
if width > height: