iOS how to manage photos - iphone

I'm creating an iOS app that works with photos.
I have built apps that do similar things on Android, and know of some of the pains that images can bring with regard to storage and memory management.
Here are my questions:
How do I save a picture that I've taken & where do I save it to (is it sensible to save it with core data somehow?)?
How do I load a picture from wherever I've saved it to?
For a tableview with images, do I need some form of lazy loading (you do on Android), if so, can anybody recommend a tutorial or library?

How do I save a picture that I've taken & where do I save it to (is it sensible to save it with core data somehow?)?
Use the system imagepicker/taker UIImagePickerController and no dont store images in CoreData. As a general rule store them in the system photo library. Store the Asset Library URL as a reference.
Images can be stored in your App documents folder also.
How do I load a picture from wherever I've saved it to?
Use the API in the AssetsLibrary framework to retrieve pictures from the system store.
For a tableview with images, do I need some form of lazy loading (you do on Android), if so, can anybody recommend a tutorial or library?
No. Lazy loading is done for free by your UITableViewController implementation. There are a 1001 great UITableView tutorials on the web.

Related

Download UI contents from a URL in flutter

I am building a flutter app that will contain a lot of animated pictures and 3d objects. Many of those animations will be choosen based on the user choice of gender when registering for the first time. So one of the issues with flutter is that it normally takes a lot of storage and with this animations its gonna need even more storage. So I was wondering if there is a way to keep those animations online in some cloud or in firestore DB and then when the user register for the first time I download it and assign it to the UI to be permenantly there instead of like storing all these Gifs in the assets.
Any suggestiong to avoid storing all of the animations and images in the assets.
Since you said you have lots of images, I would suggest you use a dedicated server to store your images.
If you haven't any dedicated server, then you should use firebase to store your images.
You should follow this link to fetch images from firebase.
Also, you should follow this link to store your images in the cache & in the future fetch from the cache easily.

How to save a large (60mb+) image to photo library?

I know the various ways to save a UIImage to the photo library:
UIImageWriteToSavedPhotosAlbum
ALAssetsLibrary
However, my images are HUGE (60mb+), so bringing them into memory is not possible. I can download the images by streaming them to disk, and even use imageWithContentsOfFile to take a peek (although that is kind of unnecessary given screen size).
But I want the user to be able to save these images for later. Is there anyway for me to get these large images into the photo library? Do I just have to keep them stored locally inside the app sandbox?
I believe that there is no point at storing them at the photo library, since it is designed to be viewed on the device and theres no point at viewing an image so big. If you want to let the user see the image then i suggest you create a preview and save THAT version into the photo library. If you want to let the user transfer them from the device to the computer there is a special folder in your app bundle which will allow those pictures to appear when using itunes and selecting your application. then he can transfer those pictures to his computer. Also could you elaborate on the characteristics of the images? format, dimentions, purpose, etc.

Creating an app that accesses all images in user's Photos for iOS?

I haven't found any documentation on this or seen this done before, but is there anyway I can, instead of just choosing one image with UIImagePicker, load the user's albums, and then after selecting an image, that image displays, but also allows me to scroll left and ride to see all the images before and after that image?
I know I can use a multiple image picker, but that involves importing all the user's photos, and if the user has hundreds of photos, this would take a lot of time. I'm looking for similar functionality to the real photos app- the performance and everything. Any ideas?
Yes, you can. Look at the documentation for ALAssetsLibrary. This will allow you to enumerate all the user's image (and video) libraries. From this, you get ALAssets, which you can ask for their default ALAssetRepresentation. This one, in turn, you ask for its CGImage, from which you can create a UIImage.
Enumerating Libraries and Assets is done in blocks, which can easily be done in the background.
Use the assets library: http://developer.apple.com/library/ios/#documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/Reference/Reference.html
An instance of ALAssetsLibrary provides access to the videos and
photos that are under the control of the Photos application.
The library includes those that are in the Saved Photos album, those
coming from iTunes, and those that were directly imported into the
device. You use it to retrieve the list of all asset groups and to
save images and videos into the Saved Photos album.
note: only available in ios 4+

How can I save images to iphone directory and retrieve it?

I want to save image in iphone album and retrieve them on particular index, how can I?
I have to save profile of many people, along with their images, so how can I access such concept?
Do not save images in iPhone album if they're your application related only.
The better way is to create directory in your application documents directory and store them there. Or even better, do use CoreData and transient property to store image on your disk to keep your data well organized.
you also have choice to save the image in sqlite3 database and retrieve it when needed.

Saving images inside iPhone application without using database or server side saving technique

I am developing an application which requires saving images in the "saved folder" of iPhone Photo album after performing some animations on ImageViews. Is it possible to save the incomplete images temporarily in the iphone application without using database or server side saving technique, so that user can use it for future use and only completely changed ones should get saved in Photo Album? If yes then it would be a great help to get any code or suggestion.
Thanks in advance :) !!!!
Sure, images can be converted to NSData objects, which can then be written to a standard file. Check out UIImagePNGRepresentation() and -[NSData writeToFile:atomically:].
You can then save to the standard native Photo album application using the technique described here (from a UIImage instance):
How to save picture to iPhone photo library?