myślę, że można to zrobić za pomocą ramy ImageIO, tak:
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
UIImage *sourceImage = [UIImage imageNamed:@"test.jpg"];
CFURLRef url = CFURLCreateWithString(NULL, CFSTR("file:///tmp/progressive.jpg"), NULL);
CGImageDestinationRef destination = CGImageDestinationCreateWithURL(url, kUTTypeJPEG, 1, NULL);
CFRelease(url);
NSDictionary *jfifProperties = [NSDictionary dictionaryWithObjectsAndKeys:
(__bridge id)kCFBooleanTrue, kCGImagePropertyJFIFIsProgressive,
nil];
NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:.6], kCGImageDestinationLossyCompressionQuality,
jfifProperties, kCGImagePropertyJFIFDictionary,
nil];
CGImageDestinationAddImage(destination, sourceImage.CGImage, (__bridge CFDictionaryRef)properties);
CGImageDestinationFinalize(destination);
CFRelease(destination);
return 0;
}
}
Preview.app mówi plik wyjściowy jest progresywny, a identify
polecenia ImageMagick mówi, że ma „przeplotu: JPEG”.
próbowałaś 'UIImageJPEGRepresentation (<# UIImage * zdjęcie #>, <# CGFloat compressionQuality #>) ' – hchouhan02
To nie czyni go progresywnym. –