riccardo-lomazzi / camera_macos

Flutter stub plugin for camera implementation for macOS
MIT License
11 stars 8 forks source link

Documentation: save as jpeg (or other non-PNG formats) #7

Closed sunilguptasg closed 10 months ago

sunilguptasg commented 1 year ago

CameraMacOSFile? file = await macOSController!.takePicture();

final directory = await getTemporaryDirectory(); // from package path_provider final fileName = <generate a file name with .jpeg extension> final filePath = '${directory. Path}/$fileName';

final image = img.decodeImage(file. Bytes!)!; // import 'package:image/image.dart' as img; io.File(filePath).writeAsBytesSync(img.encodeJpg(image, quality: 70)); // set quality - change encodeJpg to other supported formats

riccardo-lomazzi commented 10 months ago

I believe this issue was resolved with the latest PR and subsequent 0.0.7 release. You can use the new PictureFormat to set up the format in which you want your file.