mirror of
https://github.com/status-im/react-native-camera.git
synced 2025-02-24 17:58:20 +00:00
Add width property on iOS. Allows to specify an image width on capture
This commit is contained in:
parent
983337d9f8
commit
27ea6b04c2
@ -324,6 +324,17 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
|
|||||||
if ([options[@"mirrorImage"] boolValue]) {
|
if ([options[@"mirrorImage"] boolValue]) {
|
||||||
takenImage = [RNImageUtils mirrorImage:takenImage];
|
takenImage = [RNImageUtils mirrorImage:takenImage];
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
|
||||||
|
if ([options[@"width"] integerValue]) {
|
||||||
|
takenImage = [RNImageUtils scaleImage:takenImage toWidth:[options[@"width"] integerValue]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([options[@"forceUpOrientation"] boolValue]) {
|
||||||
|
takenImage = [RNImageUtils forceUpOrientation:takenImage];
|
||||||
|
}
|
||||||
|
>>>>>>> c03db73... Add width property on iOS. Allows to specify an image width on capture
|
||||||
|
|
||||||
NSMutableDictionary *response = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *response = [[NSMutableDictionary alloc] init];
|
||||||
float quality = [options[@"quality"] floatValue];
|
float quality = [options[@"quality"] floatValue];
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
+ (UIImage *)cropImage:(UIImage *)image toRect:(CGRect)rect;
|
+ (UIImage *)cropImage:(UIImage *)image toRect:(CGRect)rect;
|
||||||
+ (UIImage *)mirrorImage:(UIImage *)image;
|
+ (UIImage *)mirrorImage:(UIImage *)image;
|
||||||
+ (NSString *)writeImage:(NSData *)image toPath:(NSString *)path;
|
+ (NSString *)writeImage:(NSData *)image toPath:(NSString *)path;
|
||||||
|
+ (UIImage *) scaleImage:(UIImage*)image toWidth:(NSInteger)width;
|
||||||
+ (void)updatePhotoMetadata:(CMSampleBufferRef)imageSampleBuffer withAdditionalData:(NSDictionary *)additionalData inResponse:(NSMutableDictionary *)response;
|
+ (void)updatePhotoMetadata:(CMSampleBufferRef)imageSampleBuffer withAdditionalData:(NSDictionary *)additionalData inResponse:(NSMutableDictionary *)response;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -68,6 +68,33 @@
|
|||||||
return [fileURL absoluteString];
|
return [fileURL absoluteString];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
+ (UIImage *) scaleImage:(UIImage*)image toWidth:(NSInteger)width
|
||||||
|
{
|
||||||
|
width /= [UIScreen mainScreen].scale; // prevents image from being incorrectly resized on retina displays
|
||||||
|
float scaleRatio = (float) width / (float) image.size.width;
|
||||||
|
CGSize size = CGSizeMake(width, (int) (image.size.height * scaleRatio));
|
||||||
|
|
||||||
|
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
|
||||||
|
[image drawInRect:CGRectMake(0, 0, size.width, size.height)];
|
||||||
|
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||||
|
UIGraphicsEndImageContext();
|
||||||
|
return [UIImage imageWithCGImage:[newImage CGImage] scale:1.0 orientation:(newImage.imageOrientation)];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (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;
|
||||||
|
}
|
||||||
|
|
||||||
|
>>>>>>> c03db73... Add width property on iOS. Allows to specify an image width on capture
|
||||||
+ (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