iPhone rewrite image file - iphone

I would like to access an image file in the iPhone images directory.
Then I would like to open this file as binary and be able to rewrite it.
Assuming user has chosen this file using the UIImagePickerController, is it possible to do such thing using iPhone API?

http://developer.apple.com/library/ios/#DOCUMENTATION/AudioVideo/Conceptual/CameraAndPhotoLib_TopicsForIOS/Articles/PickinganItemfromthePhotoLibrary.html this tutorial will help you in getting UIImage from photo library.
Once you obtain the image, you can do custom modifications to the UIImage and save it to photo album using this API:
Adds the specified image to the user’s Camera Roll album.
void UIImageWriteToSavedPhotosAlbum (
UIImage *image,
id completionTarget,
SEL completionSelector,
void *contextInfo
);
If you are looking to replace the existing photo from Photo library , there is no direct (or Apple Approved) way to do that. If you still want to do that, you can find path to photo library (/private/var/mobile/Media/DCIM/100APPLE) and try rewriting the photos.

Related

Saving UIImage as PNG to photo album on iPhone

I am merging some png files to a uiimage and I followed this thread ( UIImageWriteToSavedPhotosAlbum save as PNG with transparency? )
and tried to save the result as a png file by replacing this code with my image: [self composeImageWithWidth:100 andHeight:100)..
When I test this using simulator, I go to the folder in application support and find the png there. However when I test this on a real device, I cannot find the png file in my photo album.
What could be going wrong?
Perhaps the paths of photo album?
Thanks for the answers
You can use this function:
UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);
You only need completionTarget, completionSelector and contextInfo if you want to be notified when the image is done saving, otherwise you can pass in nil.
More info here

Create, Delete, and add pictures to albums in the photos app?

Haven't seen anything, but I have seen that you can create albums in the iOS 5 photos.app, and I was curious if there is a way to integrate it in my app.
I need to be able to create the album, upload pictures to it, and be able to delete it.
Thanks,
Coulton
Since iOS5 you can programmatically add albums to Photos. See the ALAssetsLibrary Class Reference.
You can add an album (which is an ALAssetsGroup) with:
addAssetsGroupAlbumWithName:resultBlock:failureBlock:
Every ALAssetsGroup has a URL associated with it. You'll want to save it:
valueForProperty:ALAssetsGroupPropertyURL
You can then use that URL to get an ALAssetsGroup object:
groupForURL:resultBlock:failureBlock:
Once you have your ALAssetsGroup you can use addAsset: method on it to add an image or video.
Notice: all these methods are asynchronous and return immediately. You do the actual work in the blocks you pass to these methods.
See the UIImage class reference:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImage_Class/Reference/Reference.html
void UIImageWriteToSavedPhotosAlbum (
UIImage *image,
id completionTarget,
SEL completionSelector,
void *contextInfo
);
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/c/func/UIImageWriteToSavedPhotosAlbum
Adds to the camera roll album (camera) or saved photos album (no camera).

How to obtain a copied image from the pasteboard?

I have a photo editing app where I want to provide a way for the user to edit photos from the pasteboard. For example the user might copy a photo from his website in Safari and then head over to my app and choose "Open from pasteboard". Kind of like Photoshop does it.
How can I get notified or check if there is a picture or graphic (probably a UIImage) in the pasteboard? And how could I obtain that image?
I needed one for a UIImage and this snippet helped me out.
You can always extract the image out using:
UIImage *image = [UIPasteboard generalPasteboard].image;

Save UIImage into a specific PhotoAlbum

Is it possible to create a folder into a photo album where i can save my UIImage?
I use - UIImageWriteToSavedPhotosAlbum but i can't chose the specific Photo Album
Not possible with the current SDK (4.1 and lower).

Retrieving an iPhone photo saved to the photo library

I am saving images to the photo library and would like to retrieve them dynamically to display in future launches of my app. I use the WriteToSavedPhotosAlbum function, as below, but do not get any info to access the saved photo programmatically.
UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);
Once saved, is there a way to retrieve the file name/id and load an image from the photo library at a later time?
You just need to save them for yourself.
Possibly in your app's documents or cache folder.
As a side note, when you say: "display at launch", if you mean to replace the Default.png, that won't work.
The launch image must be static and included in your app bundle.
If not, disregard.
You can't, unless the user picks the photo using the UIImagePickerController.
Check this related question
try this code segment make the necessay changes
UIImagePickerController *picker=[[UIImagePickerController alloc] init];
picker.delegate=pickerDelegate;
picker.sourcetype=UIImagepickerControllerSourceTypePhtoLibrary;