Skip to content

Commit

Permalink
save images in heic format
Browse files Browse the repository at this point in the history
  • Loading branch information
parveshneedhoo committed May 22, 2024
1 parent f65d1b1 commit ff54dca
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ios/SimpleCameraPreview.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ - (void) enable:(CDVInvokedUrlCommand*)command {
}
}

self.photoSettings = [AVCapturePhotoSettings photoSettingsWithFormat:@{AVVideoCodecKey : AVVideoCodecTypeJPEG}]; [self.sessionManager setupSession:@"back" completion:^(BOOL started) {
self.photoSettings = [AVCapturePhotoSettings photoSettingsWithFormat:@{AVVideoCodecKey : AVVideoCodecTypeHEVC}]; [self.sessionManager setupSession:@"back" completion:^(BOOL started) {
dispatch_async(dispatch_get_main_queue(), ^{
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[pluginResult setKeepCallbackAsBool:true];
Expand Down Expand Up @@ -203,7 +203,7 @@ - (void) capture:(CDVInvokedUrlCommand*)command {
BOOL useFlash = [[command.arguments objectAtIndex:0] boolValue];
if (torchActivated)
useFlash = false;
self.photoSettings = [AVCapturePhotoSettings photoSettingsWithFormat:@{AVVideoCodecKey : AVVideoCodecTypeJPEG}];
self.photoSettings = [AVCapturePhotoSettings photoSettingsWithFormat:@{AVVideoCodecKey : AVVideoCodecTypeHEVC}];
if (self.sessionManager != nil)
[self.sessionManager setFlashMode:useFlash? AVCaptureFlashModeOn: AVCaptureFlashModeOff photoSettings:self.photoSettings];

Expand Down Expand Up @@ -259,9 +259,9 @@ - (NSDictionary *)getGPSDictionaryForLocation {
if (!isnan(altitude)){
if (altitude < 0) {
altitude = -altitude;
[gps setObject:@"1" forKey:(NSString *)kCGImagePropertyGPSAltitudeRef];
[gps setObject:[NSNumber numberWithInt:1] forKey:(NSString *)kCGImagePropertyGPSAltitudeRef];
} else {
[gps setObject:@"0" forKey:(NSString *)kCGImagePropertyGPSAltitudeRef];
[gps setObject:[NSNumber numberWithInt:0] forKey:(NSString *)kCGImagePropertyGPSAltitudeRef];
}
[gps setObject:[NSNumber numberWithFloat:altitude] forKey:(NSString *)kCGImagePropertyGPSAltitude];
}
Expand Down Expand Up @@ -301,7 +301,7 @@ -(void)captureOutput:(AVCapturePhotoOutput *)captureOutput didFinishProcessingPh
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef) imageData, NULL);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *libraryDirectory = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"NoCloud"];
NSString* uniqueFileName = [NSString stringWithFormat:@"%@.jpg",[[NSUUID UUID] UUIDString]];
NSString* uniqueFileName = [NSString stringWithFormat:@"%@.heic",[[NSUUID UUID] UUIDString]];
NSString *dataPath = [@"file://" stringByAppendingString: [libraryDirectory stringByAppendingPathComponent:uniqueFileName]];
CFStringRef UTI = CGImageSourceGetType(source);
CGImageDestinationRef destination = CGImageDestinationCreateWithURL((__bridge CFURLRef) [NSURL URLWithString:dataPath], UTI, 1, NULL);
Expand Down

0 comments on commit ff54dca

Please sign in to comment.