0

Is it possible to get the photos stored on the iPhone without use PHAsset ?

It's because the use of PHAsset forces me to use this method :

PHImageManager.defaultManager().requestImageForAsset( ... )

And this method takes times to be executed.

I just want to get the images directly from the folder where they're stored.

testa abalez
  • 1,042
  • 3
  • 13
  • 28
  • Probably a violation of the API/SDK EULA. – ScottMcGready Sep 07 '15 at 14:34
  • 1
    How much time does it take, and how much time would it take if you could load the image as a file? Reading several MB of data usually takes more than 1 millisecond. – Mats Sep 07 '15 at 14:42
  • To get the photo, the execution of the method I typed in my first post takes too much time. I want the photos taken by the camera. – testa abalez Sep 07 '15 at 14:46
  • How much is "too much time"? 1 hour, 1 sec, 1 usec? – zaph Sep 07 '15 at 15:22
  • It's more 1 second, because I want to made a View like the Photos app view on the iPhone, the view when we swipe right or left to see photos. And the view which I developed has a jolt when the user swipe between photos. – testa abalez Sep 08 '15 at 07:10

1 Answers1

1

It's not possible to access these files directly as they are out of the Sandbox auf your application. What takes time, when you use the method

PHImageManager.defaultManager().requestImageForAsset( ... )

is that the file gets loaded into memory and decoded into an UIImage. To avoid this please have a look at the method

PHImageManager.defaultManager(). requestImageDataForAsset( ... )

This method loads the file as NSData.

Note: If you want to build a Photo application, where users can swipe between photos, the best strategy may be the following.

  1. Preload the images the user is likely to load (e.g. one photo before and after the current displayed one) using PHCachingImageManager
  2. When the user swiped to the actual image use

    PHImageManager.defaultManager().requestImageForAsset( ... )

As the image are preloaded, this should be much quicker

Another approach would be to first load smaller thumbnail images and then with a delay load the fullscreen image.

holtmann
  • 6,043
  • 32
  • 44