jachzen / cunning_document_scanner

MIT License
79 stars 83 forks source link

Support different output formats on iOS #82

Closed mvanbeusekom closed 2 weeks ago

mvanbeusekom commented 1 month ago

First of all thank you for this great plugin, it does an amazing job.

Based on some feedback from our customers, we discovered that in many cases the scans made on iOS devices resulted in far bigger image files when comparing to scanning the same documents on an Android device.

Digging through the code base I quickly realized that this is caused be the different image formats used on the different platforms. On Android all scans are save using the JPEG format, while on iOS scans are saved using the PNG format. Comparing a simple A4 document resulted in a 7.5 MB file on on iOS, while on Android the same scan was only 450 KB in file size.

This PR adds support to supply an instance of the IosScannerOptions to the getPictures method which allows users to specify which format should be used to save scans on iOS. The parameter is optional and if not specified the plugin behaves exactly as the current version.

Example usage:

   // Returns images in PNG format. 
   final imagesPath = await CunningDocumentScanner.getPictures(
      iosScannerOptions: IosScannerOptions(
         imageFormat: IosImageFormat.png,
      ),
   );

   // Returns images in JPEG format with a compression quality of 50%. 
   final imagesPath = await CunningDocumentScanner.getPictures(
      iosScannerOptions: IosScannerOptions(
         imageFormat: IosImageFormat.jpg,
         jpgCompressionQuality: 0.5,
      ),
   );
mvanbeusekom commented 4 weeks ago

Hi @jachzen, can you please review this PR?