-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
Blurhash.encode very slow #165
Comments
Hey! This is using the algorithm from the official woltapp/blurhash library with some minor modifications to make it run in parallel. Unless you're seeing minutes of execution time, I'm guessing that this is expected - could you share some numbers? |
Hello i see but ya its taking almost a minute or more but while it's running it does not cause any sort of UI/JS blocking. The long time wait makes it feel very slow to users. Thanks. |
I think this may be a recent bug. I'm having a similar issue but it is only while encoding pictures that are immediately taken and uploaded from react-native-image-picker. Uploading and encoding an image from photo gallery is fine but it gets stuck when encoding an image that is taken from the app. |
Today I had this same bug when I was using blurhash with crop-picker. It turns out that when you give blurhash 2.3mb image to encode it takes some time. So in order to fix this, you need to compress your image to a smaller size. I was using 1000x400px image, and it took only a few seconds on iPhone 11. Using an even smaller image gives pretty much the same result but makes it even faster. |
I feel that it's not a bug, but the expected behavior according to the official blurhash Readme:
A trick that can work with
so that you get a tiny picture as *on Android, |
+1 on this issue. I let the encode run for 2 minutes before I terminated the instance and it would not compute the blurhash. I used the react-native-compressor package to shrink the file to a low quality and max dimensions of 32 x 32 and it ran instantly. It's definitely related to the image picker's output file size I believe. |
For anyone experiencing slow blurhash encoding make sure you run additional compression on the file before passing it to the blurhash. Compression of the image is super fast on iOS so it should be magnitude faster than using big images directly. |
@terrysahaidak Agreed. Would be nice if this was directly part of the encoding function to be honest, at least for iOS. Would make the package more functional on it's own. |
In my understanding, Blurhash applies a filter on top of the image and then generates a hash from that image. During the decoding process, this hash is used to create a base64 image string. This approach works well for the last 3-4 images when the base64 string is added directly to the HTML page, rather than using separate image files. However, this behavior can sometimes cause the page to crash if it contains too many images, making it less suitable for pages with a large number of images. |
Hello, thanks for this but somehow Blurhash.encode() seems to be very slow, anyhow to make faster?
The text was updated successfully, but these errors were encountered: