zoukankan      html  css  js  c++  java
  • UIImage附加信息(exif)..

    //惨痛经历,,,

    - (void)saveToAlbumWithImage:(UIImage*)image

                 completionBlock:(void (^)(NSURL *assetURL))completionBlock

                    failureBlock:(void (^)(NSError *error))failureBlock

    {

        NSData* pngData =  UIImagePNGRepresentation(image);

        

        CGImageSourceRef source = CGImageSourceCreateWithData((__bridge_retained CFDataRef)pngData, NULL);

     

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

        

        NSMutableDictionary *metadataAsMutable = [[NSMutableDictionary dictionaryWithDictionary:metadata] mutableCopy];

        

        //For EXIF Dictionary

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

        if(!EXIFDictionary)

            EXIFDictionary = [NSMutableDictionary dictionary];

        

        [EXIFDictionary setObject:@"200x300-1....." forKey:(NSString*)kCGImagePropertyExifUserComment];

        

        //add our modified EXIF data back into the image’s metadata

        [metadataAsMutable setObject:EXIFDictionary forKey:(NSString *)kCGImagePropertyExifDictionary];

        

        CFStringRef UTI = CGImageSourceGetType(source);

        

        NSMutableData *dest_data = [NSMutableData data];

        CGImageDestinationRef destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)dest_data, UTI, 1, NULL);

        

        if(destination)

        {

            CGImageDestinationAddImageFromSource(destination, source, 0, (__bridge CFDictionaryRef) metadataAsMutable);

            BOOL success = CGImageDestinationFinalize(destination);

            if(success)

            {

                //            CIImage *testImage = [CIImage imageWithData:dest_data];

                //

                //            NSDictionary *propDict = [testImage properties];//////////............由此应可知以上无误,,,,,,,

                //

                //            UIImage *newImage = [UIImage imageWithData:dest_data];

                //            NSData* pngData1 =  UIImagePNGRepresentation(newImage);

                //

                //            CGImageSourceRef source1 = CGImageSourceCreateWithData((CFDataRef)pngData1, NULL);

                //            NSDictionary *metadata1 = (__bridge NSDictionary *)(CGImageSourceCopyPropertiesAtIndex(source1, 0, NULL));

                //

                NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];

                NSString *appName = [infoDictionary objectForKey:@"CFBundleDisplayName"];

                ALAssetsLibrary *assets1Library = [[ALAssetsLibrary alloc] init];

    ////////metadataAsMutable.............定位到问题,,,,,,,

    //////............衡量标准,,,,,,,,,,,,,.......

                [assets1Library saveImage:image.CGImage metadata:metadataAsMutable toAlbum:appName completion:^(NSURL *assetURL, NSError *error) {//////...........苹果的角度..,,,,,,,,

                    completionBlock(assetURL);

                    if(destination)

                        CFRelease(destination);

                    CFRelease(source);

                } failure:failureBlock];

            }

        }

    }

     

    注:

    1.从两个点 抓取与之相关的所有信息汇总,,(细节,例:CIImage)

    2.分析判断,,(以什么标准,例:第三方查看exif)

    3.定位,,(提升高度来看,切换角度来看,,应该什么样,应该怎么做,,,例:苹果角度)

    4.解决问题,,抽象问题,,(问题的背后是什么,追溯其本质)

  • 相关阅读:
    脚本
    vim 马哥
    动态删除节点
    动态插入节点
    动态创建内容
    获取html元素内容
    设置元素的属性
    获取元素的属性
    jquery中:input和input的区别
    jQuery选择器总结
  • 原文地址:https://www.cnblogs.com/goahead-yingjun/p/4552729.html
Copyright © 2011-2022 走看看