美文网首页
iOS15.1 无法合成livePhoto

iOS15.1 无法合成livePhoto

作者: 白马青衫少年郎0 | 来源:发表于2021-10-26 14:41 被阅读0次

目前发现iOS15.1之前的版本合成livePhoto都没问题,对于刚发的iOS15.1就是合不成livePhoto

原因:发现图片信息metadata中makerApp里面的“17”写入不进去。

- (NSData *)dataByRemovingExifAndAddMakerApple:(NSString *)uuid
{
    NSData *data = self;
    CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef)data, NULL);
    NSMutableData *mutableData = nil;
    
    if (source) {
        CFStringRef type = CGImageSourceGetType(source);
        size_t count = CGImageSourceGetCount(source);
        mutableData = [NSMutableData data];
        
        CGImageDestinationRef destination = CGImageDestinationCreateWithData((CFMutableDataRef)mutableData, type, count, NULL);
        
        NSDictionary *removeExifProperties = @{(id)kCGImagePropertyExifDictionary: (id)kCFNull,
                                               (id)kCGImagePropertyGPSDictionary : (id)kCFNull,
                                               (id)kCGImagePropertyMakerAppleDictionary:@{@"17":uuid?uuid:@""}};
        
        if (destination) {
            for (size_t index = 0; index < count; index++) {
                CGImageDestinationAddImageFromSource(destination, source, index, (__bridge CFDictionaryRef)removeExifProperties);
            }
            
            if (!CGImageDestinationFinalize(destination)) {
                //                NSLog(@"CGImageDestinationFinalize failed");
            }
            
            CFRelease(destination);
        }
        
        CFRelease(source);
    }
    
    return mutableData;
}

上面是以前的写法

- (NSData *)dataByRemovingExifAndAddMakerApple:(NSString *)uuid {
    NSMutableData *data = self.mutableCopy;
    UIImage *image = [UIImage imageWithData:data];
    CGImageRef imageRef = image.CGImage;
    NSDictionary *imageMetadata = @{(NSString *)kCGImagePropertyMakerAppleDictionary : @{@"17" : uuid}};
    CFStringRef type = CGImageGetUTType(imageRef);
    CGImageDestinationRef dest = CGImageDestinationCreateWithData((CFMutableDataRef)data, type, 1, nil);
    CGImageDestinationAddImage(dest, imageRef, (CFDictionaryRef)imageMetadata);
    CGImageDestinationFinalize(dest);
    return data;
}

上面是修正后的写法

相关文章

  • iOS15.1 无法合成livePhoto

    目前发现iOS15.1之前的版本合成livePhoto都没问题,对于刚发的iOS15.1就是合不成livePhot...

  • LivePhoto

    七牛云图片处理实践之LIVE PHOTO|国内首家支持  http://blog.qiniu.com/arc...

  • iOS开发一个制作Live Photo的工具

    1.livePhoto简介 livePhoto是iOS 9.0 之后系统相机提供的拍摄动态照片的功能,但是仅在6S...

  • iOS livephoto 2022-02-23

    最近做了一个壁纸类app,涉及到了livephoto相关的内容,做个记录 基本思路 livephoto实际上是由一...

  • Livephoto的使用

    Livephoto的使用 前言 Live Photo是iPhone的一个新特性,是一段长3秒还包含声音的小视频加一...

  • iOS LivePhoto制作

    之前写了一篇iOS LivePhoto展示与保存,不过文章内介绍的是使用现有的Live Photo进行展示与保存。...

  • iOS开发 支持LivePhoto

    注意点1、获取该PHAsset是否为LivePhoto应该使用asset.mediaSubtypes.contai...

  • iOS livephoto转image

  • iOS15.1 UITableViewCell 错乱问题

    啥也不是就是static NSString *cellID = @"table_cellid"; cellID 设...

  • 2018-02-03

    漂泊的黑白。 借着浓郁的红。 混合成无法预期却又心向已久的色彩。

网友评论

      本文标题:iOS15.1 无法合成livePhoto

      本文链接:https://www.haomeiwen.com/subject/dcxyaltx.html