相关疑难解决方法(0)

如何将exif元数据写入图像(不是相机胶卷,只是UIImage或JPEG)

我知道如何使用ALAssets保存元数据.但是,我想保存一个图像,或者将其上传到某处,exif完好无损.我有exif数据作为NSDictionary.但是如何将其正确地注入UIImage(或者可能是NSData JPEG表示)?

iphone exif ios ios5

28
推荐指数
2
解决办法
3万
查看次数

在iPhone的照片库中写入UIImage以及元数据(EXIF,GPS,TIFF)

我正在开发一个项目,其要求是: - 用户将通过应用程序打开相机 - 捕获图像后,一些数据将附加到捕获图像的元数据.我已经浏览了一些论坛.我试着编写这个逻辑.我想,我已达到目的,但由于我无法看到我附加到图像的元数据,因此缺少了一些东西.我的代码是:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)dictionary 
{

    [picker dismissModalViewControllerAnimated:YES];

    NSData *dataOfImageFromGallery = UIImageJPEGRepresentation (image,0.5);
    NSLog(@"Image length:  %d", [dataOfImageFromGallery length]);


    CGImageSourceRef source;
    source = CGImageSourceCreateWithData((CFDataRef)dataOfImageFromGallery, NULL);

    NSDictionary *metadata = (NSDictionary *) CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);

    NSMutableDictionary *metadataAsMutable = [[metadata mutableCopy]autorelease];
    [metadata release];

    NSMutableDictionary *EXIFDictionary = [[[metadataAsMutable objectForKey:(NSString *)kCGImagePropertyExifDictionary]mutableCopy]autorelease];
    NSMutableDictionary *GPSDictionary = [[[metadataAsMutable objectForKey:(NSString *)kCGImagePropertyGPSDictionary]mutableCopy]autorelease];


    if(!EXIFDictionary) 
    {
        //if the image does not have an EXIF dictionary (not all images do), then create one for us to use …
Run Code Online (Sandbox Code Playgroud)

iphone exif objective-c alassetslibrary

15
推荐指数
3
解决办法
2万
查看次数

在iOS4.1上保存带照片的地理标记信息

我在iOS4.1上尝试将照片保存到带有地理标记信息的相机胶卷时遇到了重大问题.我正在使用以下ALAssetsLibrary API:

- (void)writeImageDataToSavedPhotosAlbum:(NSData *)imageData 
                                metadata:(NSDictionary *)metadata 
                         completionBlock:(ALAssetsLibraryWriteImageCompletionBlock)completionBlock
Run Code Online (Sandbox Code Playgroud)

我有GPS坐标,我想用照片作为输入保存.遗憾的是,没有文档或示例代码描述如何形成封装GPS坐标的元数据NSDictionary.有人可以发布已知有效的示例代码吗?

我也尝试使用iPhone Exif库来保存imageData中的地理信息而不是使用元数据,但遗憾的是iPhone Exif库崩溃了.任何帮助是极大的赞赏.

iphone cocoa-touch ios4 assetslibrary

12
推荐指数
3
解决办法
1万
查看次数

更新UIImage方向元数据?

基本任务:更新与UIImage关联的元数据的EXIF方向属性.我的问题是我不知道所有EXIF信息中的orientation属性.


复杂的背景:我正在改变返回的图像的方向,imagePickerController:didFinishPickingMediaWithInfo:所以我想我还需要在保存图像之前更新metaData writeImageToSavedPhotosAlbum:(CGImageRef)imageRef metadata:(NSDictionary *)metadata.

换句话说,除非我更改它,否则metaData将包含旧/初始方向,因此是错误的.我改变方向的原因是因为它在我运行Core Image面部检测程序时不停地绊倒我.使用前置摄像头在人像模式下使用iPhone(设备)拍照时,方向为UIImageOrientationRight(3).如果我重写图像使方向为UIImageOrientationUp(0),我会得到良好的面部检测结果.作为参考,下面是重写图像的例程.

整个相机定位的事情我觉得非常混乱,我似乎正在深入挖掘所有这一切的代码洞.我看了帖子(这里,这里这里.根据这篇文章(/sf/answers/264683471/):

"相机实际上是风景原生的,所以当你拍摄风景照片时,你可以向上或向下拍摄,当你拍摄照片时,你可以向左或向右拍摄(取决于你握住设备的方式)."

......这完全令人困惑.如果以上情况属实,我认为我应该使用前置摄像头UIImageOrientationLeftMirroredUIImageOrientationRightMirrored使用前置摄像头.而这一切都无法解释为什么CIDetector选择器返回的原始图像失败了.

我正在接近这个屁股,但我似乎无法面向...


-(UIImage *)normalizedImage:(UIImage *) thisImage
{
    if (thisImage.imageOrientation == UIImageOrientationUp) return thisImage;

    UIGraphicsBeginImageContextWithOptions(thisImage.size, NO, thisImage.scale);
    [thisImage drawInRect:(CGRect){0, 0, thisImage.size}];
    UIImage *normalizedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return normalizedImage;
}
Run Code Online (Sandbox Code Playgroud)

nsdictionary ios

12
推荐指数
2
解决办法
9804
查看次数

强制UIImagePickerController以纵向/尺寸iOS拍摄照片

我的应用中唯一允许的方向是横向.我在target> summery下的项目属性中强制执行此操作,并且仅允许纵向显示shouldAutorotateToInterfaceOrientation

问题是当我在水平握住手机(横向)的同时拍照时,照片将以横向拍摄,而UI仍处于纵向模式.

这意味着在横向模式下,我得到了3264 x 2448的宽图像,而不是我在纵向模式下的高图像(2448 x 3264).

接下来,用户可以裁剪图像,但如果以横向模式拍摄图像,我会得到非常难看的拉伸图像.添加边框或将UI切换为横向不是一种选择.

UIImagePickerController即使手机水平放置(横向模式),有没有办法强制以纵向尺寸拍摄照片?

UIImagePickerController使用以下设置初始化:

    imagePicker =[[UIImagePickerController alloc] init];
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
    imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
    imagePicker.showsCameraControls = NO;
    imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;
    imagePicker.wantsFullScreenLayout = YES;
    imagePicker.cameraViewTransform = CGAffineTransformScale(imagePicker.cameraViewTransform,CAMERA_TRANSFORM, CAMERA_TRANSFORM);
    imagePicker.navigationBarHidden = YES;
    imagePicker.toolbarHidden = YES;
    [self presentModalViewController:imagePicker animated:NO];
    imagePicker.cameraOverlayView = self.cameraOverlay;
    imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
Run Code Online (Sandbox Code Playgroud)

iphone xcode orientation uiimagepickercontroller

10
推荐指数
1
解决办法
1万
查看次数

将图像元数据写入iOS中的JPG/PNG文件

有没有办法将UIImage写入JPG/PNG文件,然后将元数据附加到它?我知道你可以用:

writeImageDataToSavedPhotosAlbum:元数据:completionBlock

在保存的照片中执行此操作,但是如何直接对文件执行相同的操作?我似乎无法找到任何方法来做到这一点.我知道UIImagePNGRepresentation()和UIImageJPGRepresentation()将为您提供可用于编写文件的NSData,但无法在文件中追加/替换元数据.

有任何想法吗?

iphone metadata uiimage ios

9
推荐指数
1
解决办法
5235
查看次数

修改后的EXIF数据无法正常保存

经过无数次的尝试和筛选每个SO答案+谷歌搜索结果后,让我感到困惑的是,在iOS上使用EXIF是如此令人沮丧.

下面是工作代码及其结果.

[[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:videoConnection
    completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error)
    {
        NSData *imageNSData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];

        CGImageSourceRef imgSource = CGImageSourceCreateWithData((__bridge_retained CFDataRef)imageNSData, NULL);

        //get all the metadata in the image
        NSDictionary *metadata = (__bridge NSDictionary *)CGImageSourceCopyPropertiesAtIndex(imgSource, 0, NULL);

        NSLog(@"original metadata Info: %@",metadata);

        //make the metadata dictionary mutable so we can add properties to it
        NSMutableDictionary *metadataAsMutable = [metadata mutableCopy];

        NSMutableDictionary *EXIFDictionary = [[metadataAsMutable objectForKey:(NSString *)kCGImagePropertyExifDictionary]mutableCopy];
        NSMutableDictionary *GPSDictionary = [[metadataAsMutable objectForKey:(NSString *)kCGImagePropertyGPSDictionary]mutableCopy];
        NSMutableDictionary *RAWDictionary = [[metadataAsMutable objectForKey:(NSString *)kCGImagePropertyRawDictionary]mutableCopy];

        if(!EXIFDictionary)
            EXIFDictionary = [[NSMutableDictionary dictionary] …
Run Code Online (Sandbox Code Playgroud)

camera exif photo ios

6
推荐指数
1
解决办法
5293
查看次数

使用UIIImagePicker的CGAffineTransform缩放UIImage并保存到Parse SDK

我使用以下代码来扩展我的UIImagePickerController.

    CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 71.0); //This slots the preview exactly in the middle of the screen by moving it down 71 points
    self.imagePicker.cameraViewTransform = translate;
    CGAffineTransform scale = CGAffineTransformScale(translate, 1.333333, 1.333333);
    self.imagePicker.cameraViewTransform = scale;
Run Code Online (Sandbox Code Playgroud)

然后我把照片呈现出来 UIImageView

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    [picker dismissViewControllerAnimated:NO completion:NULL];

    _imageTaken = nil;
    _imageTaken = [info objectForKey:UIImagePickerControllerEditedImage];
    if(_imageTaken==nil)
    {
        _imageTaken = [info objectForKey:UIImagePickerControllerOriginalImage];
    }
    if(_imageTaken==nil)
    {
        _imageTaken = [info objectForKey:UIImagePickerControllerCropRect];
    }

    [_imageTakenView setContentMode:UIViewContentModeScaleAspectFill];

    if (_selfie) {
        UIImage * flippedImage = [UIImage imageWithCGImage:_imageTaken.CGImage …
Run Code Online (Sandbox Code Playgroud)

objective-c uiimageview uiimage ios

4
推荐指数
1
解决办法
543
查看次数

PHAsset位置 - GPS元数据,有什么问题?

尝试使用Phasset从UIImage添加位置:

// image is a variable like so: image: UIImage

var newAsset = PHAssetChangeRequest.creationRequestForAssetFromImage(image)
newAsset.location = CLLocation(latitude: coordinate.latitude, coordinate.longitude)
Run Code Online (Sandbox Code Playgroud)

显然,这段代码可以工作 - >将新资源保​​存到具有良好坐标的照片库中.我可以在图书馆里看到它.

但是当我使用exif工具和类似工具时,大多数时候,GPS字典是空的,好像没有设置位置.(另外,我注意到GPS信息不是exif格式)所以我想,位置信息也在其他地方......

那么PHAsset的位置属性有什么问题?如何设置正确的位置?

ios swift photokit

4
推荐指数
1
解决办法
4065
查看次数

调整大小和设置JPEG图像的质量,同时在iOS中保留EXIF

在iOS应用中,我有一个NSData对象,它是一个JPEG文件,需要将其调整为给定的分辨率(2048x2048),并且需要将JPEG质量设置为75%。需要在将EXIF数据保留在文件中的同时进行设置。该照片不在相机胶卷中-它是从DSLR相机通过网络拉出的,只是与应用程序临时存储在一起。如果图像通过UIImage行程,则EXIF数据将丢失。如何在不丢失EXIF的情况下执行调整大小和设置质量?还是有一种方法可以在转换前剥离EXIF数据,并在完成后将其添加回去?

exif objective-c nsdata ios

0
推荐指数
1
解决办法
2031
查看次数