fluttercandies / flutter_image_compress

flutter image compress
MIT License
633 stars 214 forks source link

Error: UnimplementedError for compressWithList #250

Open Ballistx opened 1 year ago

Ballistx commented 1 year ago

Content

I am using the following method to load an image which I want to draw on a canvas. However I always get the error message "Error: UnimplementedError" for compressWithList which exists twice. The one with the throw UnimplementedError() in class UnsupportedFlutterImageCompress and the actual one without throw UnimplementedError() in FlutterImageCompressPlatform.

Future<UI.Image> loadUiImage(
      String imageAssetPath, int height, int width) async {
    final ByteData data = await rootBundle.load(imageAssetPath);
    Uint8List uint8list = data.buffer.asUint8List();

    final Uint8List compressedData = await FlutterImageCompress.compressWithList(
      uint8list,
      minHeight: height,
      minWidth: width,
      quality: 100, // Adjust the quality level as needed
      //format: CompressFormat.png,
    );
    final codec = await UI.instantiateImageCodec(
      compressedData,
      targetHeight: height,
      targetWidth: width,
    );

    return (await codec.getNextFrame()).image;
  }
MzeeAlii commented 1 year ago

Yep, same error.

minhson3756 commented 1 year ago

Maybe you used it in another isolate, just use it in the main isolate

lakshmanprabhu49 commented 10 months ago

@minhson3756 You are right, it works on main isolate. But this is pretty intensive process right? Do you know any technique to put it in a different isolate?

GhagSagar23 commented 8 months ago

Any idea when will this functionality be implemented? @minhson3756.

gcostaapps commented 4 months ago

Any updates? As this task is CPU intensive it would be good if it could run outside the main isolate.