CGImageCreateWithPNGDataProvider()
returns nil
if the provided data is not in PNG format (for example JPEG or TIFF).
[UIImage imageWithData: imageData]
returns an image for all supported image file formats (PNG, JPEG, TIFF etc.)
This explains why the first function can fail while the second succeeds.