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.解决问题,,抽象问题,,(问题的背后是什么,追溯其本质)

  • 相关阅读:
    【动态规划】多重背包
    【动态规划】完全背包问题
    【背包问题】0-1背包、完全背包、多重背包、混合三种背包、二位费用背包、分组背包
    HDU1712ACboy needs your help【分组背包】
    关于kettle
    面向接口编程
    MS Sql添加描述信息 及其他信息
    记录我一个特别酷的梦
    EF 线程内唯一对象
    javascript 学习犯错记录
  • 原文地址:https://www.cnblogs.com/goahead-yingjun/p/4552729.html
Copyright © 2011-2022 走看看