Uploading image issue (UIImageJPEGRepresentation vs UIImagePNGRepresentation)

前端 未结 2 2213
旧时难觅i
旧时难觅i 2021-02-08 09:08

I have stored a few pictures using Safari\'s \"Hold + Save Image\" option to my Photo Library in simulator. When I pick an image from the library, I have to convert it to JPEG o

2条回答
  •  萌比男神i
    2021-02-08 09:41

    Regarding your third point, you can determine the image type loaded from the library in your image picker delegate method as follows:

    - (void)imagePickerController:(UIImagePickerController *)picker 
    didFinishPickingMediaWithInfo:(NSDictionary *)info {
    
        // Get the image reference URL
        NSURL *referenceURL = [info objectForKey:UIImagePickerControllerReferenceURL];
    
        // The path extension contains the image type: JPG, PNG, GIF, etc.
        NSString *originalImageType = referenceURL.pathExtension; 
    
    }
    

提交回复
热议问题