Estoy intentando crear un archivo JPEG progresivo desde un objeto UIImage
, este es el código que estoyCreación JPEG progresivo en IOS con ImageIO produce resultados en bloques en el dispositivo
NSMutableData *data = [NSMutableData data];
NSString *path = [NSHomeDirectory() stringByAppendingPathComponent: @"Library/Caches/test.jpg"];
CFURLRef url = CFURLCreateWithString(NULL, (CFStringRef)[NSString stringWithFormat:@"file://%@", path], 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:.7], kCGImageDestinationLossyCompressionQuality,
jfifProperties, kCGImagePropertyJFIFDictionary,
nil];
CGImageDestinationAddImage(destination, ((UIImage*)object).CGImage, (__bridge CFDictionaryRef)properties);
CGImageDestinationFinalize(destination);
CFRelease(destination);
Esto funciona muy bien cuando se ejecuta en el simulador , pero lamentablemente produce resultados gruesos/en bloques en el dispositivo:
alguna idea de lo que está pasando? volvería a usar UIImageJPEGRepresentation
como último recurso, realmente necesito archivos JPEG progresivos.
¿Cuál es la versión de iOS? – Raptor
@ShivanRaptor ha sido probado con iOS 5.0 - 5.1.1 –
Estoy tratando de probar los códigos con mi teléfono. ¿Puedes compartir el 'test.jpg' que estás usando? – Raptor