fluttercandies / flutter_image_editor

Flutter plugin, support android/ios.Support crop, flip, rotate, color martix, mix image, add text. merge multi images.
Apache License 2.0
419 stars 129 forks source link

[Discussions] Too slow when the image source is large #108

Closed tong-k-k closed 1 year ago

tong-k-k commented 1 year ago

Content

Is there any trick or how to use this plugin properly when dealing with large image?

I think it is too slow, like when just do a rotation, on a large image.

It pause a while, around 3-5 sec, to do a just rotation.

So any tips? below is my code snippet


  Future<void> _rotate(RotateOption rotateOpt) async {
    _handleOption(<Option>[rotateOpt]);
  }

  Future<void> _handleOption(List<Option> options) async {
    for (int i = 0; i < options.length; i++) {
      final Option o = options[i];
      imageEditorOption.addOption(o);
    }

    final Uint8List? result = await ImageEditor.editImage(
      image: editedImageByte!,
      imageEditorOption: imageEditorOption,
    );

    if (result == null) {
      _setImageProvider(null);
      return;
    }

    editedImageByte = result;
    final MemoryImage img = MemoryImage(result);
    _setImageProvider(img);
  }

  void _setImageProvider(ImageProvider? provider) {
    this.provider = provider;
    setState(() {});
  }

onPressed: () {
                _rotate(const RotateOption(90));
              },