ios 图片操作

http://stackoverflow.com/questions/3837115/display-image-from-url-retrieved-from-alasset-in-iphone    display image from URL retrieved from ALAsset in iPhone

http://stackoverflow.com/questions/1282830/uiimagepickercontroller-uiimage-memory-and-more UIImagePickerController, UIImage, Memory and More? [closed]

http://blog.csdn.net/sdhjob/article/details/6942793  IPad开发拍照并将图片保存到照片库中

http://stackoverflow.com/questions/1238838/uiimagepickercontroller-and-extracting-exif-data-from-existing-photos  UIImagePickerController and extracting EXIF data from existing photos

1.把图片写入文件

- (BOOL)writeImage:(UIImage*)image toFileAtPath:(NSString*)aPath
{
if ((image == nil) || (aPath == nil) || ([aPath isEqualToString:@""]))
return NO;
@try
{
NSData *imageData = nil;

NSString *ext = [aPath pathExtension];

if ([ext isEqualToString:@"png"])
{
imageData = UIImagePNGRepresentation(image);
NSLog(@"png");
}
else
{
NSLog(@"jpg");
// the rest, we write to jpeg
// 0. best, 1. lost. about compress.
imageData = UIImageJPEGRepresentation(image, 0);
}
if ((imageData == nil) || ([imageData length] <= 0))
return NO;
[imageData writeToFile:aPath atomically:YES];
return YES;
}
@catch (NSException *e)
{
NSLog(@"create thumbnail exception.");
}
return NO;
}

2.从文件加载图片

-(UIImage *)loadImageFromFile:(NSString *) aPath;
{
UIImage *im=[[UIImage alloc] initWithContentsOfFile:[self dataFilePath:aPath]];
if (im==nil)
NSLog(@"nil %@",[self dataFilePath:aPath]);
return im;
}



3. uiimage大小

image.size.width,image.size.height


4.点击图片响应事件

    resizedImageView.userInteractionEnabled = YES;
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(photoTapped)];
[resizedImageView addGestureRecognizer:singleTap];//点击图片事件
NSLog(@"haha");
[self.view addSubview:resizedImageView];//加载图片



原文地址:https://www.cnblogs.com/phoenix13suns/p/2351368.html