Instance Method

jpegData(compressionQuality:)

Returns a data object containing the specified image in JPEG format.

Declaration

func jpegData(compressionQuality: CGFloat) -> Data?

Parameters

image

The original image data.

compressionQuality

The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality).

Return Value

A data object containing the JPEG data, or nil if there was a problem generating the data. This function may return nil if the image has no data or if the underlying CGImageRef contains data in an unsupported bitmap format.

Discussion

If the image object’s underlying image data has been purged, calling this function forces that data to be reloaded into memory.

See Also

Exporting Standard Bitmap Formats

func pngData() -> Data?

Returns a data object containing the specified image in PNG format