Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9177541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:20:58+00:00 2026-06-17T17:20:58+00:00

I can easily save to camera roll images taken with camera. But I don’t

  • 0

I can easily save to camera roll images taken with camera.
But I don’t want to save the image if this is chosen from the camera roll, because it will create a duplicate.

How can I do the following and selectively saving to camera roll?

EDIT 1:
As rmaddy said I can:
Only save to the camera roll if picker.sourceType is equal to UIImagePickerControllerSourceTypeCamera.

but if I do that, I won’t be able to get the info of the selected image, the filename mainly.

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];

if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

    [self.myImageView setImage: image];
    [self.myImageView setContentMode:UIViewContentModeScaleAspectFit];
    ALAssetsLibrary *al=[[ALAssetsLibrary alloc] init];

    // ------> Saving to Camera Roll <------------

    [al writeImageToSavedPhotosAlbum:[image CGImage] metadata:nil completionBlock:^(NSURL *assetURL,NSError *error) { 

            ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myAsset) {
                ALAssetRepresentation *rep = [myAsset defaultRepresentation];
                NSString *fileName = [rep filename];
                ImageInfo *imgInfo = [[ImageInfo alloc] initWithEventId:0 name:fileName image:UIImageJPEGRepresentation(image, 1.0)];
                imgInfo.isDirty = YES;
                [self.imagesArray addObject:imgInfo];
                [self dismissViewControllerAnimated:YES completion:nil];
                NSLog(@"Image from Camera %@ added to imageArray",fileName);
            };

            ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc]init];
            [assetsLibrary assetForURL:assetURL
                           resultBlock:resultblock
                          failureBlock:nil];

     }];
}
else if ([mediaType isEqualToString:(NSString *)kUTTypeMovie])
{
    // Code here to support video if enabled
}

EDIT 2:

SOLVED WITH THIS MOD:
(I know that there is a little bit of code duplication, I will try to improve it later)

if (newMedia){
        ALAssetsLibrary *al=[[ALAssetsLibrary alloc] init];
        [al writeImageToSavedPhotosAlbum:[image CGImage] metadata:nil completionBlock:^(NSURL *assetURL,NSError *error)
        {                
            ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myAsset)
            {
                ALAssetRepresentation *rep = [myAsset defaultRepresentation];
                //NSString *fileName = [rep filename];
                NSString *imgUrl = [[rep url] absoluteString];
                ImageInfo *imgInfo = [[ImageInfo alloc] initWithEventId:0 imgUrl:imgUrl image:UIImageJPEGRepresentation(image, 1.0)];
                imgInfo.isDirty = YES;
                [self.imagesArray addObject:imgInfo];
                [self dismissViewControllerAnimated:YES completion:nil];
                NSLog(@"Image from Camera %@ added to imageArray",imgUrl);
            };

            ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc]init];
            [assetsLibrary assetForURL:assetURL
                           resultBlock:resultblock
                          failureBlock:nil];
        }];
} else {
        NSString* imgUrl = UIImagePickerControllerReferenceURL;
        ImageInfo *imgInfo = [[ImageInfo alloc] initWithEventId:0 imgUrl:imgUrl image:UIImageJPEGRepresentation(image, 1.0)];
        imgInfo.isDirty = YES;
        [self.imagesArray addObject:imgInfo];
        NSLog(@"Image from Camera Roll %@ added to imageArray",imgUrl);
        [self dismissViewControllerAnimated:YES completion:nil];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:20:59+00:00Added an answer on June 17, 2026 at 5:20 pm

    Only save to the camera roll if picker.sourceType is equal to UIImagePickerControllerSourceTypeCamera.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a camera that returns raw images that can easily be converted to
I can generate a client from http://localhost:8080/service?wsdl just fine, but now I want to
I want to save complex Excel file to html format. It can be easily
I can easily check IP addresses programmatically, but is there any way to set
We can easily alert anything in java script. Is it possible to get this
From Eclipse I can easily run all the JUnit tests in my application. I
Using scons I can easily set my include paths: env.Append( CPPPATH=['foo'] ) This passes
Using MVCContrib you can easily do RedirectToAction calls such as this.RedirectToAction( c => c.List()
I'd like to save an array to disk so that I can easily read
I have a DataSet consisting of XML data, I can easily output this to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.