George Sachpatzidis George Sachpatzidis - 3 months ago 12
Objective-C Question

UIImagePickerController check if user edited the image

I am using a

UIImagePickerController
with the property
allowsEditing
set to
YES
.

When the user finish picking an image I want to know if the user edited the image he selected or not (e.g. if he scaled the image). This method:

UIImage *editedImage = [info objectForKey:@"UIImagePickerControllerEditedImage"];


returns always an object even if the user left the picture as it was. Is there any way to check if the user edited the image? For example can i check if the
UIImagePickerControllerEditedImage
and
UIImagePickerControllerOriginalImage
are different somehow?

Answer

Try this in didFinishPickingMediaWithInfo as i am not sure:

 UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

 UIImage *editedimage = [info objectForKey:UIImagePickerControllerEditedImage];

 if ([UIImagePNGRepresentation(image) isEqualToData:UIImagePNGRepresentation(editedimage)])
  //not edited
 else
  //edited