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

feat: 3656 - optimized JPEG compression #3682

Merged
merged 1 commit into from
Feb 8, 2023

Conversation

monsieurtanuki
Copy link
Contributor

New file:

  • image_compute_helper.dart: Optimized methods for BMP and JPEG file computations.

Impacted files:

  • background_task_image.dart: now using new optimized saveJpeg method
  • new_crop_page.dart: now using new saveBmp method for performances; added a progress indicator; refactored
  • pubspec.lock: wtf
  • pubspec.yaml: added package flutter_image_compress; refactored
  • rotated_crop_image.dart: fixed a bug regarding dispose

What

  • Image upload operation could appear to be slow.
  • The main reason is that the standard flutter image JPEG compression method is slow.
  • With this PR
    • we use the native JPEG compression methods, that are way faster.
    • for the "transient" file, we even save the file as BMP, which is faster to encode.
    • In addition to that, we now display a progress indicator when we click on the "Send image!" button, for a better UX.
  • UX could be improved using isolates (no app freezing), but I currently could not find time for this.

Part of

New file:
* `image_compute_helper.dart`: Optimized methods for BMP and JPEG file computations.

Impacted files:
* `background_task_image.dart`: now using new optimized `saveJpeg` method
* `new_crop_page.dart`: now using new `saveBmp` method for performances; added a progress indicator; refactored
* `pubspec.lock`: wtf
* `pubspec.yaml`: added package `flutter_image_compress`; refactored
* `rotated_crop_image.dart`: fixed a bug regarding `dispose`
@monsieurtanuki
Copy link
Contributor Author

Note to myself: use isolates for image compression with the new flutter 3.7 feature: background isolate channels.

Copy link
Member

@M123-dev M123-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @monsieurtanuki

Also the new isolate changes look promising

@monsieurtanuki
Copy link
Contributor Author

Thank you very much @M123-dev for your review!

@monsieurtanuki monsieurtanuki merged commit 0fd2b6b into openfoodfacts:develop Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants