1 -(void)pngAndJpg:(UIImage*)image{
 2     NSString  *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.png"];
 3     NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.jpg"];
 4     
 5     // Write a UIImage to JPEG with minimum compression (best quality)
 6     // The value 'image' must be a UIImage object
 7     // The value '1.0' represents image compression quality as value from 0.0 to 1.0
 8     [UIImageJPEGRepresentation(image, 1.0) writeToFile:jpgPath atomically:YES];
 9     
10     // Write image to PNG
11     [UIImagePNGRepresentation(image) writeToFile:pngPath atomically:YES];
12     
13     // Let's check to see if files were successfully written...
14     
15     // Create file manager
16     NSError *error;
17     NSFileManager *fileMgr = [NSFileManager defaultManager];
18     
19     // Point to Document directory
20     NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
21     
22     // Write out the contents of home directory to console
23     NSLog(@"Documents directory: %@", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]);
24     
25 }

 

相关文章:

  • 2021-05-21
  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
  • 2022-12-23
  • 2022-01-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案