Я использую функцию автоматического улучшения, чтобы улучшить много изображений.
Но, похоже, большая утечка, поэтому вот код, который я использую:
#import <CoreImage/CoreImage.h>
#import <ImageIO/ImageIO.h>
@implementation UIImage (AutoEnhanced)
- (UIImage *)autoEnhancedImage
{
@autoreleasepool {
CIImage *ciOriginal = self.CIImage;
if(!ciOriginal) {
ciOriginal = [[CIImage alloc] initWithCGImage:self.CGImage];
}
NSDictionary *options = @{ CIDetectorImageOrientation : @(self.CGImagePropertyOrientation)};
NSArray *adjustments = [ciOriginal autoAdjustmentFiltersWithOptions:options];
for (CIFilter *filter in adjustments) {
[filter setValue:ciOriginal forKey:kCIInputImageKey];
ciOriginal = filter.outputImage;
}
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef cgImage = [context createCGImage:ciOriginal fromRect:ciOriginal.extent];
UIImage *enhancedImage = [[UIImage alloc] initWithCGImage:cgImage];
CGImageRelease(cgImage);
return enhancedImage;
}
}
- (CGImagePropertyOrientation)CGImagePropertyOrientation
{
switch (self.imageOrientation) {
case UIImageOrientationUp:
return kCGImagePropertyOrientationUp;
case UIImageOrientationUpMirrored:
return kCGImagePropertyOrientationUpMirrored;
case UIImageOrientationDown:
return kCGImagePropertyOrientationDown;
case UIImageOrientationDownMirrored:
return kCGImagePropertyOrientationDownMirrored;
case UIImageOrientationLeftMirrored:
return kCGImagePropertyOrientationLeftMirrored;
case UIImageOrientationRight:
return kCGImagePropertyOrientationRight;
case UIImageOrientationRightMirrored:
return kCGImagePropertyOrientationRightMirrored;
case UIImageOrientationLeft:
return kCGImagePropertyOrientationLeft;
}
}
@end
А вот журнал из Инструментов:
![enter image description here](https://i.stack.imgur.com/KKuFj.jpg)
Даже с авто-выпуском я не могу это исправить. Любая идея будет очень ценится! Спасибо!