Skip to content

cant store multiple sized thumbnails with get_thumbnail() #121

@suneelkingrani

Description

@suneelkingrani

Hi @pylover , a nice piece of work!

I am trying to make different sizes/widths of thumbnails e.g. width=30 or width=40. For that I am following the basic setup given in your repository /examples/flask. But for some reason I am unable to save/update multiple thumbnails.

suppose I have a Person with an avatar field defined and I want to create two different sized thumbnails:

with StoreManager(db.session()):
	thumbnail = person1.avatar.get_thumbnail(width=32, auto_generate=True)
	db.session.commit()

The value of avatar field in DB, after running the code lines above:

{"key": "ae01a10b-e33f-4234-a1ad-aa32c01ca92c", "extension": ".png", "content_type": "image/png", "reproducible": false, "width": 128, "height": 125, "length": 28101, "timestamp": "1564068229.4194794", "thumbnails": [[32, 31, 0.25, {"key": "54813146-c03c-42c0-8ebe-91d505055ab5", "width": 32, "height": 31, "extension": ".png", "content_type": "image/png", "reproducible": false, "length": 2272, "timestamp": "1564071128.3401299"}]]}

and when I re run the same code to get another thumbnail of different width (40) i.e.:

with StoreManager(db.session()):
	thumbnail = person1.avatar.get_thumbnail(width=40, auto_generate=True)
	db.session.commit()

It does not change anything in avatar field in DB, though I guess it is supposed to append a list for another thumbnail in avatar thumbnails.
Also re running the method get_thumbnail(width=40, auto_generate=True), keeps making new image files in thumbnail directory and changes nothing in the DB.

Can you please let me know if I am doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions