-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
Price proof: convert images to webp before upload ? #5952
Comments
Could be done on the server side when receiving the image file, right?
flutter is not very good converting images: something like slow actions that freeze the app.
That would mean discarding the offline mode. Or maintaining both online and offline mode. What's supposed to happen with slow connectivity? |
The idea is to have both. But if done on the mobile, users would send a ~1MB image, instead of a 10MB image. Good for slow connectivity, no ?
I'm no expert, but we do background tasks already in the mobile app, we want to put some AI, so an image conversion shouldn't be that hard ? |
Actually we don't really care about speed as we do that in background.
It's not hard, it takes resources, for instance we have to save and keep the image in BMP (instead of directly in JPEG) most of the time for performance reasons, and eventually convert it in JPEG but in background (cf. image_compute_container.dart) And there are two different modes. Let's say the user selects a photo from the gallery. We support only JPEG here. Then:
|
@raphodn Which compression rate do you use for your webp conversions? |
In the web app I use compressor.js
I tested setting the quality to 1, and instead of dividing the size by 5-6, it actually increases it 👀 |
@raphodn Things don't look that good in https://pub.dev/packages/flutter_image_compress#webp
Looks like a no-go for iOS: it would freeze the app (and for no apparent reason for the user as it's in background tasks). That said, I've just noted that our current quality factor for JPEG is... 100 (percents I guess). |
@raphodn I've run some tests around quality and compress format on an android device, regarding size in bytes:
Given that using webp in flutter would be problematic, as explained earlier, an easy win would be to lower the quality of compression from 100 to 80 for prices proofs. What do you think about it? |
Thanks for the tests and the images ! I tried in the frontend using the current compressjs library, and doing the same thing (conversion to JPG 80%). Results here. The output size is 2x webp, but still a factor or 4-5 compared to the original image. And it retains EXIF. So maybe an alternative path could indeed be :
cc @raphael0202 |
|
Story
In the Open Prices project we've been discussing the idea to convert as much of our images to webp. Why ? No quality impact, but a big size impact (factor of 5-7), all the seconds reduced to upload an image to the server.
This conversion is already done in the web app - prices.openfoodfacts.org.
What about doing it in the mobile app ?
Especially if we want to seperate the "proof upload" and "price upload" actions, and have the proof uploaded as soon as possible so that the server can return the "predictions" (proof type, price/product/location extraction...)
Linked to openfoodfacts/open-prices#577
The text was updated successfully, but these errors were encountered: