jbww
jbww

Reputation: 765

Save a UIImage to a different name

I am writing an application which lets the user pick one photograph from a selection. Then I want to save that photograph to their photo roll to a specific name. i.e I always want the photo in the roll to be named the same thing and overwrite previous selections.

    UIImage* image = [UIImage imageNamed:[ImageNames objectAtIndex:self.miImage]];

    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

I can't find anyway to make a copy of the image and assign a new name to it, or specify a target name for UIImageWriteToSavedPhotosAlbum().

Is there any way to do this?

thanks in advance,

Jay

Upvotes: 2

Views: 2706

Answers (1)

Evan Mulawski
Evan Mulawski

Reputation: 55334

You cannot specify a filename when using UIImageWriteToSavedPhotosAlbum because it saves the image to the Camera Roll (or the Photos Library, if the device does not have a camera). This allows the system to assign it a name based on a format, like "DSC0001.jpg" or similar, and avoid name collisions.

Because of this, overwriting an image is also not possible, since the Photo Library / Camera Roll are controlled by the user - a user that would not appreciate a photo being overwritten by your application.

...writing the image to the user’s Camera Roll or Saved Photos album.

UIImageWriteToSavedPhotosAlbum Reference

Upvotes: 13

Related Questions