mirror of
https://github.com/status-im/react-native-camera.git
synced 2025-02-24 17:58:20 +00:00
Merge pull request #1290 from Snapp-FidMe/force_portrait_on_ios
Add ability to force portrait orientation on IOS
This commit is contained in:
commit
6f69f7b033
@ -246,6 +246,8 @@ Supported options:
|
|||||||
|
|
||||||
- `exif` (boolean true or false) Use this with `true` if you want a exif data map of the picture taken on the return data of your promise. If no value is specified `exif:false` is used.
|
- `exif` (boolean true or false) Use this with `true` if you want a exif data map of the picture taken on the return data of your promise. If no value is specified `exif:false` is used.
|
||||||
|
|
||||||
|
- `forceUpOrientation` (iOS only, boolean true or false). This property allows to force portrait orientation based on actual data instead of exif data.
|
||||||
|
|
||||||
The promise will be fulfilled with an object with some of the following properties:
|
The promise will be fulfilled with an object with some of the following properties:
|
||||||
|
|
||||||
- `width`: returns the image's width (taking image orientation into account)
|
- `width`: returns the image's width (taking image orientation into account)
|
||||||
|
@ -324,6 +324,9 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
|
|||||||
if ([options[@"mirrorImage"] boolValue]) {
|
if ([options[@"mirrorImage"] boolValue]) {
|
||||||
takenImage = [RNImageUtils mirrorImage:takenImage];
|
takenImage = [RNImageUtils mirrorImage:takenImage];
|
||||||
}
|
}
|
||||||
|
if ([options[@"forceUpOrientation"] boolValue]) {
|
||||||
|
takenImage = [RNImageUtils forceUpOrientation:takenImage];
|
||||||
|
}
|
||||||
|
|
||||||
NSMutableDictionary *response = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *response = [[NSMutableDictionary alloc] init];
|
||||||
float quality = [options[@"quality"] floatValue];
|
float quality = [options[@"quality"] floatValue];
|
||||||
@ -336,6 +339,8 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
|
|||||||
if ([options[@"base64"] boolValue]) {
|
if ([options[@"base64"] boolValue]) {
|
||||||
response[@"base64"] = [takenImageData base64EncodedStringWithOptions:0];
|
response[@"base64"] = [takenImageData base64EncodedStringWithOptions:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ([options[@"exif"] boolValue]) {
|
if ([options[@"exif"] boolValue]) {
|
||||||
int imageRotation;
|
int imageRotation;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
+ (UIImage *)generatePhotoOfSize:(CGSize)size;
|
+ (UIImage *)generatePhotoOfSize:(CGSize)size;
|
||||||
+ (UIImage *)cropImage:(UIImage *)image toRect:(CGRect)rect;
|
+ (UIImage *)cropImage:(UIImage *)image toRect:(CGRect)rect;
|
||||||
+ (UIImage *)mirrorImage:(UIImage *)image;
|
+ (UIImage *)mirrorImage:(UIImage *)image;
|
||||||
|
+ (UIImage *)forceUpOrientation:(UIImage *)image;
|
||||||
+ (NSString *)writeImage:(NSData *)image toPath:(NSString *)path;
|
+ (NSString *)writeImage:(NSData *)image toPath:(NSString *)path;
|
||||||
+ (void)updatePhotoMetadata:(CMSampleBufferRef)imageSampleBuffer withAdditionalData:(NSDictionary *)additionalData inResponse:(NSMutableDictionary *)response;
|
+ (void)updatePhotoMetadata:(CMSampleBufferRef)imageSampleBuffer withAdditionalData:(NSDictionary *)additionalData inResponse:(NSMutableDictionary *)response;
|
||||||
|
|
||||||
|
@ -68,6 +68,17 @@
|
|||||||
return [fileURL absoluteString];
|
return [fileURL absoluteString];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (UIImage *)forceUpOrientation:(UIImage *)image
|
||||||
|
{
|
||||||
|
if (image.imageOrientation != UIImageOrientationUp) {
|
||||||
|
UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale);
|
||||||
|
[image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
|
||||||
|
image = UIGraphicsGetImageFromCurrentImageContext();
|
||||||
|
UIGraphicsEndImageContext();
|
||||||
|
}
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
+ (void)updatePhotoMetadata:(CMSampleBufferRef)imageSampleBuffer withAdditionalData:(NSDictionary *)additionalData inResponse:(NSMutableDictionary *)response
|
+ (void)updatePhotoMetadata:(CMSampleBufferRef)imageSampleBuffer withAdditionalData:(NSDictionary *)additionalData inResponse:(NSMutableDictionary *)response
|
||||||
{
|
{
|
||||||
CFDictionaryRef exifAttachments = CMGetAttachment(imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
|
CFDictionaryRef exifAttachments = CMGetAttachment(imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user