<!--
{
  "availability" : [
    "iOS: 8.0.0 - 12.0.0",
    "iPadOS: 8.0.0 - 12.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.10.0 - 10.14.0",
    "tvOS: -",
    "visionOS: 1.0.0 - 1.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIColorKernel/init(source:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core Image"
    ],
    "preciseIdentifier" : "c:objc(cs)CIColorKernel(cm)kernelWithString:"
  },
  "title" : "init(source:)"
}
-->

# init(source:)

Creates a color kernel object from the specified kernel source code.

```
convenience init?(source string: String)
```

## Parameters

`string`

A program in the Core Image Kernel Language that contains a single routine marked using the `kernel` keyword.

## Return Value

A new color kernel object, or `nil` if the specified source code does not contain a valid color kernel routine.

## Discussion

This method is similar to the [`init(source:)`](/documentation/CoreImage/CIKernel/init(source:)) method of the superclass [`CIKernel`](/documentation/CoreImage/CIKernel), but creates only color kernels. Use this method when you want to ensure that the type of kernel object returned (if any) is always [`CIColorKernel`](/documentation/CoreImage/CIColorKernel).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)