Register | Login

» Slow photo saving and lack of EXIF with the iPhone API

April 22nd, 2009

Filed under Development

Comments (6)

By Johnny Kwan

Two of the issues that have been bugging our Darkroom and Darkroom Premium camera apps are the slow photo saving time and the lack of EXIF information, such as geo-tagging, in the saved photos. Of course, there are various factors that could affect the performance and functionality of the application, but the core cause of these problems is in the API provided by Apple to perform such functions.

We have recently submitted bugs reports regarding the iPhone SDK to Apple ahead of the final 3.0 release. One such problem that came back to us was about the lack of EXIF information in the photos saved using the iPhone API. We were asked to provide a sample application to demonstrate the problem, and so we did.

Here is the sample application if you really want to give it a spin yourself: Test Camera

It’s really quite simple:

That’s it. We don’t care to remove the view or anything after the photo is taken, since all we need is to take 1 photo. We then open up the saved photo and check its EXIF, and low and behold… wa la~ nothing! (except for the dimensions), just like the photo saved in Darkroom (well, of course! That’s what we are testing for).

The problem actually lies with UIImage, the data parameter that feeds into UIImageWriteToSavedPhotosAlbum. UIImage actually strips off any extra EXIF information on the image, even if you try to add them with library such as iphone-exif.

To save an image with EXIF using iphone-exif, you would have to add the extra EXIF information to an NSData representation of the UIImage and write the file directly to disk. However, with the available API, you can only write to the PhotoAlbum using UIImageWriteToSavedPhotosAlbum, which only accept UIImage. Once you convert the NSData back to an UIImage, all the EXIF information is lost again! And we are back to square one.

One extra bonus we did get from this little experiment is that we can also get the time required to simply save an image using the default API. What we did is to add some extra logging before and after the call to UIImageWriteToSavedPhotosAlbum.

2009-04-22 13:00:18.591 TestCamera[187:20b] Saving...
 
2009-04-22 13:00:26.469 TestCamera[187:20b] Saved. Error message (if any): (null)
 
2009-04-22 13:01:04.990 TestCamera[192:20b] Saving...
 
2009-04-22 13:01:13.351 TestCamera[192:20b] Saved. Error message (if any): (null)
 
2009-04-22 13:02:32.090 TestCamera[197:20b] Saving...
 
2009-04-22 13:02:39.489 TestCamera[197:20b] Saved. Error message (if any): (null)
 
2009-04-22 13:07:38.332 TestCamera[202:20b] Saving...
 
2009-04-22 13:07:45.689 TestCamera[202:20b] Saved. Error message (if any): (null)

The time it took to perform just the UIImageWriteToSavedPhotosAlbum call is on average 7.75 seconds ((7.878 + 8.361 + 7.399 + 7.357) /4) on a freshly restarted iPhone. It would take a fair bit longer if tested on an iPhone that has been running other apps prior to running the test.

Given the results from the above tests, how does the default camera app save the photo so much faster and with geo-tagging in the EXIF as well? The answer is, because Apple’s own apps don’t use the publicized API, but instead use their internal hidden private methods. They can skip all the bottleneck caused by the publicized API, and do things that honest 3rd party developers cannot do. All we can do, is to wait patiently to see if Apple is merciful enough to provide updates or fixes to make our lives (and the users’) much easier.

Latest Post

6 Comments


  • simon852

    OIC! Just wondering! Hope Apple would fix/release these secret tools soon! ^.^


  • 23

    Can you publish or send me the radr bug number for the bug you filed so we can log a duplicate?


  • Johnny Kwan

    23:
    It’s 6807099.
    Just wondering, how do you “log a duplicate”? or even check for others’ submitted bugs?


  • Tobias

    But somehow it must be possible to get an image with geo data out of the camera.
    Because if you open an image taken with the Camera app on a Desktop, it has valid geo-data attached. At least that is what Pixelmator showed me.

    What do you think?


  • acoward

    Was this ever fixed?


  • Martin Kou

    The Camera app saves directly to .ithmb files in ~/Media/Photos, which is raw YUV encoded, and so it’s fast – I highly suspect they have yet another performance reason for using YUV instead of RGB there. UIImageWriteToSavedPhotosAlbum(), on the other hand, compresses the full res image to JPEG and then saves to ~/Media/DCIM. The compression step alone in an iPhone 3G takes 6 seconds.

    This seems like a screw up on Apple’s part – they probably had two different teams to handle the Camera app itself and the saving API so they ended up using different methods.

    A possible way out is to reverse engineer the .ithmb and the “Photo Database”’s file formats and write to them directly. But Apple may not allow such an app to pass review.

  • Allowed

  • You can use these tags
  • Allow 5 minutes between posts
  • * = Required fields
  • You can follow any responses to this entry through the RSS 2.0 feed.
  • Leave a Reply