add width/height for works
This commit is contained in:
parent
e52a5458b9
commit
d4aada517b
3 changed files with 8 additions and 1 deletions
BIN
images.db
BIN
images.db
Binary file not shown.
|
@ -92,8 +92,13 @@ def processWork(work : models.Artwork):
|
|||
f = loadEmotionsFromMs(work.filename)
|
||||
work.faces = f
|
||||
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)
|
||||
|
||||
work.width = img.size[0]
|
||||
work.height = img.size[1]
|
||||
work.save()
|
||||
|
||||
img.thumbnail((200,200))
|
||||
img.save(work.getThumbPath())
|
||||
return
|
||||
|
|
|
@ -58,6 +58,8 @@ class Artwork(BaseModel):
|
|||
emotion = ForeignKeyField(Emotion, related_name='artworks', index=True)
|
||||
created_date = DateTimeField(default=datetime.datetime.now)
|
||||
filename = CharField()
|
||||
width = IntegerField(null=True)
|
||||
height = IntegerField(null=True)
|
||||
colours = ColoursField(null=True) # serialised colours + percentages: [([r,g,b], percentage), ...]
|
||||
faces = JsonField(null=True) # Serialised MS data
|
||||
|
||||
|
|
Loading…
Reference in a new issue