UIImagePNGRepresentation and UIImageJPEGRepresentation

UIImagePNGRepresentation is the most expensive and least efficient way to save an image, but it can be used if you need to save an image that doesn’t have transparent pixels. This method creates an NSData instance of the image. The NSData can be saved to a file, such as a PNG or JPEG. The quality of the file can be controlled by using the compressionQuality parameter. CompressionQuality values below 1.0 can cause a loss in quality, while values below 0.9 can cause a more significant loss in quality.

UIImageJPEGRepresentation can be used to save an image as a JPEG, and will reduce the file size. However, this method can also cause loss in image quality. NSData has a compressionQuality parameter which can be set to 1.0, and this will mitigate the loss in quality. The resulting NSData will be larger, and slower to upload. This method is the second best way to save an image.

UIImageJPEGRepresentation will also save a new image, and this new image won’t contain any camera metadata. This can be a good thing. However, you will need to decide whether or not you want to accept the loss of image quality.

UIImagePNGRepresentation is a good choice for the highest quality images. However, it has the largest memory footprint, and the largest data size. It can also be disqualified for memory impact tests. In order to avoid this, you should set the NSString *mimeType parameter dynamically, and avoid using a default jpeg type.

The second best way to save an image is to create a UIImage from data. This can be done by using the CGImageSourceCreateWithData method. The CGImageSourceCreateWithData function calls the ImageIO method, and can result in a large CPU footprint. CGImageSourceCreateWithData also has a parameter, ShouldCache, which is set by default on 64-bit devices. The parameter, ShouldCache, can be set to false if you don’t need it.

Another option is to use CoreGraphics. With CoreGraphics, you can take a snapshot of any part of your application. After saving your image, you can save it to a file, or use it for page turning scenarios. CoreGraphics supports saving the image as a PNG or JPEG, and you can use the contentMode and UIImageView methods to display the image. You can also use the UIViewContentModeScaleAspectFit method to scale the image to fit the frame. This method also maintains the image’s aspect ratio. This is useful in situations where an image may be used as a pattern. This method can be used with iOS albums. However, you may not be able to upload an image larger than 800px on each side. This can cause problems when you try to upload to web services. You may also be limited to images smaller than 32px x 32px.

In addition to saving images, CoreGraphics can also be used to create transitions and other effects. The CoreGraphics API provides access to raw metadata. This metadata can be stored or edited by the user.