---
title: "#32:  Core Image Basics 🌄"
url: https://littlebitesofcocoa.com/32-core-image-basics
author: Jake Marsh
date: 2015-07-07
published: 2015-07-07
topics: ["Core Image","Images"]
description: "CoreImage has long been a staple on OS X, and was added to iOS a few years ago. It's an incredibly feature-packed image processing API that can apply just..."
---

# #32:  Core Image Basics 🌄

By Jake Marsh, July 7, 2015. HTML: https://littlebitesofcocoa.com/32-core-image-basics

**CoreImage** has long been a staple on **OS X**, and was added to **iOS** a few years ago. It's an incredibly feature-packed image processing API that can apply just about any type of filter or image manipulation you can dream of. Let's take a look at applying a simple color tint to an image:

``` swift
func applyFilterToImage(image: UIImage) -> UIImage {
  guard let inputImage = image.CIImage else { return image }

  let tintColor = CIColor(red: 0.55, green: 0.33, blue: 0.22)

  let filter = CIFilter(
    name: "CIColorMonochrome",
    withInputParameters: [
      "inputImage" : inputImage,
      "inputColor" : tintColor,
      "inputIntensity" : 1.0
    ]
  )

  return UIImage(CIImage: filter!.outputImage)
}
```

**CoreImage** works on `CIImages` not `UIImages`, so we convert our image to a `CIImage`, and use guard since the `CIImage` property on `UIImage` is optional. **CoreImage** also doesn't use `UIColor`, so we create a `CIColor` instead.

Then the fun part, we create our filter by name. **CoreImage** has literally 100's of different filters available, and instead of subclasses, you instantiate them by name.

`CIFilters` also don't have explicit class properties, you instead supply values for *"Input Parameters"* on your filter.

Lastly, we apply the filter by simply asking for it's `outputImage`.

<img src="https://media.littlebitesofcocoa.com/bite-assets/032-coreimage-basics-before-after.png" style="max-width: 384px;" />
