CoreImage Raw image editing - Working Wide Color - Display P3

Updated
Mar 28, 2021 12:49 PM
Created
Mar 25, 2021 5:18 PM
Tags
SwiftCoreImage
Keywords
Date

505_live_photo_editing_and_raw_processing_with_core_image (1).pdf3033.5KB

image

image

image

image

writeJPEGRepresentationOfImage:toURL:colorSpace:options:error:

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

createCGImage(_:from:format:colorSpace:deferred:)

Creates a Quartz 2D image from a region of a Core Image image object with deferred rendering.

Sharing for other platforms

CGImageDestination

CGImageDestinationOptimizeForSharing - kCGImageDestinationOptimizeColorForSharing

import MobileCoreServices

func makeImageForJPEGOptimizedSharing(image: CGImage, quality: CGFloat = 1) -> Data {
  let data = NSMutableData()

  let destination = CGImageDestinationCreateWithData(
    data,
    kUTTypeJPEG,
    1,
    [:] as CFDictionary
  )!

  CGImageDestinationAddImage(
    destination,
    image,
    [
      kCGImageDestinationLossyCompressionQuality : quality,
      kCGImageDestinationOptimizeColorForSharing: true,
    ] as CFDictionary)

  CGImageDestinationFinalize(destination)

  return data as Data
}