Copying a JPEG image with CGImage changes file size
Copying a JPEG image with CGImage changes file size
- Subject: Copying a JPEG image with CGImage changes file size
- From: Hugo Duncan <email@hidden>
- Date: Wed, 9 Apr 2008 15:36:28 -0700 (PDT)
Hi,
I am wanting to edit metadata in a JPEG, and am just testing
code (below) to read and write out an image without modification using CGImage to make sure I can do so without changing the image. I am unable to obtain an
output file which is identical to the input file. Any suggestions? have tried setting kCGImageDestinationLossyCompressionQuality to 1.0.
Thanks,
Hugo
// Load the image
NSURL *absURL= [NSURL fileURLWithPath:@"testImage.JPG"];
CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)absURL, NULL);
size_t numImages=CGImageSourceGetCount(source);
// Create an image destination writing to `url'
NSURL *absURL2= [NSURL fileURLWithPath:@"testImageOutput.JPG"];
CGImageDestinationRef dest =
CGImageDestinationCreateWithURL((CFURLRef)absURL2,
(CFStringRef)@"public.jpeg", numImages, nil);
size_t i=0;
for (i=0; i<numImages; ++i)
{
CFMutableDictionaryRef mMetadata = (CFMutableDictionaryRef)CGImageSourceCopyPropertiesAtIndex(source, i, nil);
CGImageDestinationAddImageFromSource(dest, source, i, mMetadata);
}
BOOL status = CGImageDestinationFinalize(dest);
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden