fluttercandies / flutter_image_compress

flutter image compress
MIT License
633 stars 214 forks source link

[Bug report] #247

Open PrzemyslawPluszowy opened 1 year ago

PrzemyslawPluszowy commented 1 year ago

Version

2.0.3

Platforms

dart

Device Model

emulator

flutter info

/data/user/0/com.example.new_app/cache/43e263ae-5d36-4e92-8d71-eb39f929ea257380969216658532980.jpg
E/flutter ( 5143): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter_image_compress_platform_interface/src/validator.dart': Failed assertion: line 23 pos 9: '(name.endsWith('.jpg') || name.endsWith('.jpeg'))': The jpeg format name must end with jpg or jpeg.

How to reproduce?

image path is jpg, but plugin don't comperss

Logs

No response

Example code (optional)

Future<void> pickImage({required ImageSource source}) async {
    final ImagePicker picker = ImagePicker();
    final Directory tempDir = await getTemporaryDirectory();

    final XFile? getImage = await picker.pickImage(source: source);
    if (getImage != null) {
      final XFile? image =
          await testCompressAndGetFile(File(getImage.path), tempDir.path);
      if (image != null) {
        setState(() {
          _imageAvatar = File(image.path);
        });
      } else {
        print('no image selected');
      }
    }
  }

Contact

No response

YamazakiKunq commented 1 year ago

FlutterImageCompress.validator.ignoreCheckExtName = true; add this line, before the compress method

gopelkujo commented 10 months ago

FlutterImageCompress.validator.ignoreCheckExtName = true; add this line, before the compress method

Thanks! this solve my problem when i try to use webp & heic format.