Instance Method

writeJPEGRepresentationOfImage:toURL:colorSpace:options:error:

Renders the image and exports the resulting image data as a file in JPEG format.

Declaration

- (BOOL)writeJPEGRepresentationOfImage:(CIImage *)image toURL:(NSURL *)url colorSpace:(CGColorSpaceRef)colorSpace options:(NSDictionary<CIImageRepresentationOption, id> *)options error:(NSError * _Nullable *)errorPtr;

Parameters

image

The image object to render.

url

The file URL at which to write the output JPEG file.

colorSpace

The color space in which to render the output image. This color space must conform to either the kCGColorSpaceModelRGB or kCGColorSpaceModelMonochrome model and must be compatible with the specified pixel format.

options

A dictionary with additional options for export. Use the kCGImageDestinationLossyCompressionQuality key to specify JPEG compression level.

errorPtr

On input, a pointer to an error object. If an error occurs, this pointer is set to an object containing error information.

Return Value

If YES, file export succeeded. If NO, examine the errorPtr parameter for possible failure reasons.

Discussion

To render an image for export, the image’s contents must not be empty and its extent dimensions must be finite. To export after applying a filter whose output has infinite extent, see the imageByClampingToExtent method.

See Also

Rendering Images for Data or File Export

- TIFFRepresentationOfImage:format:colorSpace:options:

Renders the image and exports the resulting image data in TIFF format.

- JPEGRepresentationOfImage:colorSpace:options:

Renders the image and exports the resulting image data in JPEG format.

- PNGRepresentationOfImage:format:colorSpace:options:

Renders the image and exports the resulting image data in PNG format.

- HEIFRepresentationOfImage:format:colorSpace:options:

Renders the image and exports the resulting image data in HEIF format.

- writeTIFFRepresentationOfImage:toURL:format:colorSpace:options:error:

Renders the image and exports the resulting image data as a file in TIFF format.

- writePNGRepresentationOfImage:toURL:format:colorSpace:options:error:

Renders the image and exports the resulting image data as a file in PNG format.

- writeHEIFRepresentationOfImage:toURL:format:colorSpace:options:error:

Renders the image and exports the resulting image data as a file in HEIF format.

kCIImageRepresentationAVDepthData

options dictionary key for image export methods to represent data as AVDepthData.

kCIImageRepresentationDepthImage

options dictionary key for image export methods to output depth data.

kCIImageRepresentationDisparityImage

options dictionary key for image export methods to output disparity data.