superlistapp / super_native_extensions

Native drag & drop, clipboard access and context menu.
MIT License
450 stars 79 forks source link

[super_clipboard] Get ANY image data as Uint8List? #350

Open ds797 opened 5 months ago

ds797 commented 5 months ago

Is it possible to ignore format and get any image data as Uint8List?

knopp commented 5 months ago

The format argument in Reader.getFile is nullable. You should be able to call the method with null format which should give you any file in the clipboard.

Kinwailo commented 2 months ago

Reader.getFile return null if the format argument is null.

Exception0x0194 commented 2 months ago

It seems that the package does not provide compound formats like Formats.image, but adding entries manually works out:

final imageFormat = SimpleFileFormat(
    uniformTypeIdentifiers: ['public.jpeg', 'public.png'],
    windowsFormats: ['JFIF', 'PNG'],
    mimeTypes: ['image/jpeg', 'image/png'],
  );

Now the imageFormat refers to gif and jpg at the same time, which can be used at reading files with multiple possible formats:

reader.getFile(imageFormat, (file) async {
    final data = await file.readAll();
    // Do sth with data...
}

I wonder if the package could provide easy declarations for compound formats🤔

Things like these would be much more convenient:

final imageFormat = Formats.png | Formats.jpeg | Formats.webp | Formats.bmp;

... or add something like Formats.any to read any file as stream / bytes?