UIImageJPEGRepresentation produces Magenta Cast on iPhone 5s iOS 7

Originator:rainmkr26
Number:rdar://15127095 Date Originated:10/1/2013
Status:Open Resolved:
Product:iOS Product Version:7.0
Classification: Reproducible:Always
 
Summary:
Using UIImageJPEGRepresentation to convert a UIImage produces a magenta cast/tint in the shadow area of images.

Side by side comparison between a file modified on another device and a file saved as a jpg on a 5S. The 5S appears to save the file with a slight color tint. This may be due to a color profile influencing this code:
    NSData *data = UIImageJPEGRepresentation(image, 1.0);
    [data writeToURL:outputURL atomically:YES];

Steps to Reproduce:
NSFileManager *defaultManager = [NSFileManager defaultManager];
NSURL *docsURL = [[defaultManager URLsForDirectory:NSDocumentDirectory
                                             inDomains:NSUserDomainMask] lastObject];
NSURL *outputURL = [docsURL URLByAppendingPathComponent:@"new.jpg"];

UIImage *image = [UIImage imageNamed:@"gray.jpg"];
NSData *data = UIImageJPEGRepresentation(image, 1.0);
[data writeToURL:outputURL atomically:YES];

UIImage *newImage = [UIImage imageWithContentsOfFile:[outputURL path] ];

imageView.image = image;
imageView2.image = newImage;
        
        UIImage *newImage = [UIImage imageWithData:imageData];

        NSData *jpegData = UIImageJPEGRepresentation(newImage, 1.0);
        [jpegData writeToFile:filePath atomically:YES];

Expected Results:
that the two images be identical visually and in the file system

Actual Results:
new.jpg has a magenta cast/tint

Version:
iOS 7.0.x iPhone 5s

Notes:


Configuration:


Attachments:
'gray.jpg' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!