Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7767981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:48:24+00:00 2026-06-01T15:48:24+00:00

I am creating an Image Processing app that does two image analysis functions. One

  • 0

I am creating an Image Processing app that does two image analysis functions. One is to read the RGB data of the image and the other is to read the EXIF data. I am taking a photo with the front camera and then saving it to the documents folder. To grab the RGB values I load the image in this manner:

NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.jpg"];
UIImage *image = [UIImage imageWithContentsOfFile:jpgPath];
CFDataRef pixelData = CGDataProviderCopyData(CGImageGetDataProvider(image.CGImage));
const UInt8* data = CFDataGetBytePtr(pixelData);

This works as expected and I can get the pixel data. My issue is gathering the EXIF data. I am implementing the reading of my image in the same manner as RGB and all my EXIF data comes back as NULL.

NSString *EXIFPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.jpg"];
NSURL *url = [NSURL fileURLWithPath:EXIFPath];

CGImageSourceRef sourceRef = CGImageSourceCreateWithURL((__bridge CFURLRef)url, NULL);

NSDictionary *immutableMetadata = (__bridge NSDictionary *) CGImageSourceCopyPropertiesAtIndex(sourceRef,0,NULL);
NSDictionary *exifDic = [immutableMetadata objectForKey:(NSString *)kCGImagePropertyExifDictionary];

NSNumber *ExifApertureValue  = [exifDic objectForKey:(NSString*)kCGImagePropertyExifApertureValue];
NSNumber *ExifShutterSpeed  = [exifDic objectForKey:(NSString*)kCGImagePropertyExifShutterSpeedValue];

NSLog(@"ExifApertureValue : %@ \n",ExifApertureValue);
NSLog(@"ExifShutterSpeed : %@ \n",ExifShutterSpeed);

If I change the first line of code to read a preloaded image in the app like this:

NSString *aPath = [[NSBundle mainBundle] pathForResource:@"IMG_1406" ofType:@"JPG"];

It works. The problem is I can not preload the images. They must be taken live from the camera. Any suggestions are greatly appreciated. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:48:25+00:00Added an answer on June 1, 2026 at 3:48 pm

    How does that file Test.jpg get written to the Documents directory? Is it written with UIImageJPEGRepresentation? If so, the EXIF data will be lost. Make sure you store the JPEG source for any images you need the metadata for.

    Regardless of what’s happening, it will help to log the full immutableMetadata and exifDic objects as soon as you retrieve them.

    NSDictionary *immutableMetadata = (__bridge NSDictionary *) CGImageSourceCopyPropertiesAtIndex(sourceRef,0,NULL);
    NSLog(@"immutableMetadata = %@", immutableMetadata);
    NSDictionary *exifDic = [immutableMetadata objectForKey:(NSString *)kCGImagePropertyExifDictionary];
    NSLog(@"exifDic");
    

    If your exifDic log only contains these three values, it’s been saved by a function that didn’t care about preserving the EXIF headers.

    exifDic = {
        ColorSpace = 1;
        PixelXDimension = 1200;
        PixelYDimension = 1600;
    }
    

    Two other things that work, but could be better:

    (1) There’s no guarantee that the Documents directory will be a subdirectory of NSHomeDirectory(). The reliable way to get this Documents location is as follows:

    NSArray *documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentDirectory = [documentDirectories objectAtIndex:0];
    NSString *imagePath = [documentDirectory stringByAppendingPathComponent:@"Test.jpg"];
    

    (2) You’re currently loading the image bytes from storage twice, once to get pixels and once to get the metadata. Load them into an NSData object, and you only have to retrieve the file once. Keep that NSData object, and you can save the image later without losing any detail. (This will consume memory equal to the file size, so only keep it if you need it.)

    NSData *imageData = [NSData dataWithContentsOfFile:imagePath];
    UIImage *image = [UIImage imageWithData:imageData];
    // Do things involving image pixels...
    
    CGImageSourceRef sourceRef = CGImageSourceCreateWithData((__bridge CFDataRef) imageData, NULL);
    // Do things involving image metadata...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a GUI for image processing in PyQt. One task that I
I am new in c#. I am working on image processing. I am creating
I'm currently having trouble creating an image from a binary string of data in
I am creating a buffered image that is going to be a snapshot of
I am creating an image processing application in C# and trying to take advantage
I'm creating image gallery with drag functionality (like on iPhone). It gets data from
I'm creating a Java application for image processing , and after a while of
My fellow developer and I are creating an iPhone app that is creating a
I'm creating a basic blog app with rails/mongoid backend and an iOS client that
I'm working on a task that includes image processing. I've found out, that I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.