openfoodfacts / smooth-app

🤳🥫 The new Open Food Facts mobile application for Android and iOS, crafted with Flutter and Dart
https://world.openfoodfacts.org/open-food-facts-mobile-app?utm_source=off&utf_medium=web&utm_campaign=github-repo
Apache License 2.0
865 stars 285 forks source link

Price proof: convert images to webp before upload ? #5952

Open raphodn opened 4 days ago

raphodn commented 4 days ago

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 https://github.com/openfoodfacts/open-prices/issues/577

monsieurtanuki commented 3 days ago

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.

Could be done on the server side when receiving the image file, right?

This conversion is already done in the web app - prices.openfoodfacts.org. What about doing it in the mobile app ?

flutter is not very good converting images: something like slow actions that freeze the 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...)

That would mean discarding the offline mode. Or maintaining both online and offline mode. What's supposed to happen with slow connectivity?

raphodn commented 3 days ago

Could be done on the server side when receiving the image file, right?

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 ?

flutter is not very good converting images: something like slow actions that freeze the app.

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 ?

monsieurtanuki commented 3 days ago

Good for slow connectivity, no ?

Actually we don't really care about speed as we do that in background.

an image conversion shouldn't be that hard

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: