@@ -34,8 +34,7 @@ - (void) didDetectRectangle:(CIRectangleFeature *)rectangle withType:(IPDFRectan
3434
3535- (void ) capture {
3636 [self captureImageWithCompletionHander: ^(UIImage *croppedImage, UIImage *initialImage, CIRectangleFeature *rectangleFeature) {
37-
38- if (self.onPictureTaken ) {
37+ if (self.onPictureTaken ) {
3938 NSData *croppedImageData = UIImageJPEGRepresentation (croppedImage, self.quality );
4039
4140 if (initialImage.imageOrientation != UIImageOrientationUp) {
@@ -58,10 +57,24 @@ - (void) capture {
5857 @" bottomLeft" : @{ @" y" : @(rectangleFeature.bottomRight .x ), @" x" : @(rectangleFeature.bottomRight .y )},
5958 @" bottomRight" : @{ @" y" : @(rectangleFeature.topRight .x ), @" x" : @(rectangleFeature.topRight .y )},
6059 } : [NSNull null ];
61- self.onPictureTaken (@{
62- @" croppedImage" : [croppedImageData base64EncodedStringWithOptions: NSDataBase64Encoding64CharacterLineLength ],
63- @" initialImage" : [initialImageData base64EncodedStringWithOptions: NSDataBase64Encoding64CharacterLineLength ],
64- @" rectangleCoordinates" : rectangleCoordinates });
60+
61+ if (self.useBase64 ) {
62+ self.onPictureTaken (@{
63+ @" croppedImage" : [croppedImageData base64EncodedStringWithOptions: NSDataBase64Encoding64CharacterLineLength ],
64+ @" initialImage" : [initialImageData base64EncodedStringWithOptions: NSDataBase64Encoding64CharacterLineLength ],
65+ @" rectangleCoordinates" : rectangleCoordinates });
66+ } else {
67+ NSString *croppedFilePath = [NSTemporaryDirectory () stringByAppendingPathComponent: [NSString stringWithFormat: @" cropped_img_%i .jpeg" ,(int )[NSDate date ].timeIntervalSince1970]];
68+ NSString *initialFilePath = [NSTemporaryDirectory () stringByAppendingPathComponent: [NSString stringWithFormat: @" initial_img_%i .jpeg" ,(int )[NSDate date ].timeIntervalSince1970]];
69+
70+ [croppedImageData writeToFile: croppedFilePath atomically: YES ];
71+ [initialImageData writeToFile: initialFilePath atomically: YES ];
72+
73+ self.onPictureTaken (@{
74+ @" croppedImage" : croppedFilePath,
75+ @" initialImage" : initialFilePath,
76+ @" rectangleCoordinates" : rectangleCoordinates });
77+ }
6578 }
6679 [self stop ];
6780 }];
0 commit comments