add width/height for works

This commit is contained in:
Ruben 2017-03-11 11:57:28 +01:00
parent e52a5458b9
commit d4aada517b
3 changed files with 8 additions and 1 deletions

BIN
images.db

Binary file not shown.

View file

@ -92,8 +92,13 @@ def processWork(work : models.Artwork):
f = loadEmotionsFromMs(work.filename) f = loadEmotionsFromMs(work.filename)
work.faces = f work.faces = f
work.save() work.save()
if not os.path.exists(work.getThumbPath()): if not os.path.exists(work.getThumbPath()) or work.width is None or work.height is None:
img = Image.open(work.filename) img = Image.open(work.filename)
work.width = img.size[0]
work.height = img.size[1]
work.save()
img.thumbnail((200,200)) img.thumbnail((200,200))
img.save(work.getThumbPath()) img.save(work.getThumbPath())
return return

View file

@ -58,6 +58,8 @@ class Artwork(BaseModel):
emotion = ForeignKeyField(Emotion, related_name='artworks', index=True) emotion = ForeignKeyField(Emotion, related_name='artworks', index=True)
created_date = DateTimeField(default=datetime.datetime.now) created_date = DateTimeField(default=datetime.datetime.now)
filename = CharField() filename = CharField()
width = IntegerField(null=True)
height = IntegerField(null=True)
colours = ColoursField(null=True) # serialised colours + percentages: [([r,g,b], percentage), ...] colours = ColoursField(null=True) # serialised colours + percentages: [([r,g,b], percentage), ...]
faces = JsonField(null=True) # Serialised MS data faces = JsonField(null=True) # Serialised MS data