Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image persistence does not work #11

Open
codeswhite opened this issue Oct 27, 2024 · 5 comments
Open

Image persistence does not work #11

codeswhite opened this issue Oct 27, 2024 · 5 comments
Assignees

Comments

@codeswhite
Copy link
Contributor

No description provided.

@codeswhite codeswhite changed the title Persist settings via localstorage Image persistence does not work Oct 27, 2024
@async3619
Copy link
Owner

@codeswhite can you give me some info about what env did you test? (e.g. os, browser, etc.)

@codeswhite
Copy link
Contributor Author

I was getting this error:

image

It turns out the image was apparently too big (4.4 MB).

After looking into it:
The max quota is 5120 by default.
But because we are storing the image in base64 we should take encoding overhead into consideration (which is 33% for base64).
Also we store it together with other JSON variables which also take space.

I suggest to change the 5MB soft limit to something lower, for example:
5120
Minus 500 bytes for JSON and other settings
Multiply by 0.75 to account base64 overhead
=> 3465 bytes for the image

@async3619
Copy link
Owner

I was getting this error:

image

It turns out the image was apparently too big (4.4 MB).

After looking into it:
The max quota is 5120 by default.
But because we are storing the image in base64 we should take encoding overhead into consideration (which is 33% for base64).
Also we store it together with other JSON variables which also take space.

I suggest to change the 5MB soft limit to something lower, for example:
5120
Minus 500 bytes for JSON and other settings
Multiply by 0.75 to account base64 overhead
=> 3465 bytes for the image

gosh thanks for suggestion I'll deal with it

btw it would be nicer to store image into somewhere else (like IndexedDB)

@async3619 async3619 self-assigned this Oct 28, 2024
@spj2401Dev
Copy link

My quick and dirty suggestion would be to compress the image. I mean its blured anyway so you could probably get away with it.

@codeswhite
Copy link
Contributor Author

@spj2401Dev
I like your thinking, but JPEG and PNG formats are already compressed, so adding an additional layer of compression wont help very much (maybe like -10% in size).

But like @async3619 said, IndexedDB would be a better solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants