Search code examples
uiimagepngformatjpegphotolibrary

How can I know the format of a UIImage? (IOS)


Very simple question.

Is there any way to tell whether a picture picked from the photo library is a jpg file or a png file?

Since some other app's work may also be in the library, so I need to know this.

More specifically, what I need is only to tell whether that photo is a JPEG image.

Thanks !


Solution

  • Did you try this?

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
    

    This UIImagePickerControllerDelegate has a parameter called editingInfo. This dictionary contains a value for a key called UIImagePickerControllerMediaType. This tells about the image type.