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
407 stars 124 forks source link

is GIF crop supported ? #96

Open Nico3652 opened 2 years ago

Nico3652 commented 2 years ago

Hi there,

The crop is working great for .jpg or .png but I'm not able to crop an animated GIF with this method :

 Future<Uint8List?> cropImageDataWithNativeLibrary(
      ExtendedImageEditorState? state) async {
    final Rect? cropRect = state!.getCropRect();
    final EditActionDetails? action = state.editAction;

    Uint8List? result;

    if (action != null) {
      final int rotateAngle = action.rotateAngle.toInt();
      final bool flipHorizontal = action.flipY;
      final bool flipVertical = action.flipX;
      final Uint8List img = state.rawImageData;

      final ImageEditorOption option = ImageEditorOption();

      if (action.needCrop && cropRect != null) {
        option.addOption(ClipOption.fromRect(cropRect));
      }

      if (action.needFlip) {
        option.addOption(
            FlipOption(horizontal: flipHorizontal, vertical: flipVertical));
      }

      if (action.hasRotateAngle) {
        option.addOption(RotateOption(rotateAngle));
      }

      result = await ImageEditor.editImage(
        image: img,
        imageEditorOption: option,
      );
    }
    return result;
  }

Is the GIF crop is supported ? I also tried editImageAndGetFile() but get no result.

How can this be done ? Thanks for help