takoyaro / db-storage1111

automatic1111's stable-diffusion-webui extension for storing images to a database
49 stars 19 forks source link

Extract Image #2

Closed Blackened15 closed 1 year ago

Blackened15 commented 1 year ago

Have you been able to see or extract image from the DB? Everytime I try to use the supposed base64 bindata in an HTML file or some base64 image viewer, it never works https://jaredwinick.github.io/base64-image-viewer/.

If I take the actual image saved on my disk and convert it to base64, it has no problem displaying when pasted inside an HTML file or a website viewer. Also (obviously) the string of bindata is completely different.

I'm sure I'm missing something here.

takoyaro commented 1 year ago

Actually you're not missing anything, you are right on point.

I'm not familar with python methods but I think I might be encoding an already encoded string here: https://github.com/takoyaro/db-storage1111/blob/8c706d2feaa5957f3d4a60e878fc0cc4a08e0f73/scripts/storage.py#L61

Will have to test.

By decoding the retrieved base64, it will show up properly... <img src="data:image/png;base64, {atob(pic.image)}" />

I'm currently on a short trip away from home, will try to squeeze a fix in during the train ride tomorrow

Blackened15 commented 1 year ago

Ok, worked, managed (well, chatgpt did with some educated prompting) to build a small webserver that show me the image in the database.