Home

Awesome

ShinpuruImage

Syntactic Sugar for Accelerate/vImage and Core Image Filters

Screenshot

ShinpuruImage offers developers a consistent and strongly typed interface to Apple's Core Image and vImage/Accelerate image filters without the need for boilerplate code.

ShinpuruImage filters are implemented as extensions to UIImage and can be chained together with a super easy syntax:

        let image = UIImage(named: "vegas.jpg")!
            .SIFastBlur(width: 10, height: 10, backgroundColor: UIColor.redColor())
            .SIMonochrome(color: UIColor.yellowColor(), intensity: 1)
            .SIRotate(angle: 0.3, backgroundColor: UIColor.purpleColor())

Installation

ShinpuruImage consists of three Swift files and to use ShinpuruImage in your own project, you simply need to copy:

Filters

Photo Effects

Color Effects

Stylize

Blur

Color Adjustment

Morphology functions

High Level Geometry Functions

Convolution

Histogram

<img src="/ShinpuruImage/assets/HistogramScreenShot.jpg" align="center" width="300" >

Demo Application

The demo app contains three components:

Filter Chaining

For the best perfomance when chaining image filters together, Shinpuru Image includes a SIFastChainableImage type that prevents the chain from converting to UIImage between individual chained filters. The syntax is slightly different and requires the source UIImage to be cast to a SIFastChainableImage and the final output to be converted back to a UIImage:

            let image = UIImage(named: "oculista.jpg")!

            let chained = SIFastChainableImage(image: image)
                .SIPhotoEffectFade()
                .SIGaussianBlur(radius: 5)
                .SIFalseColor(color0: UIColor.blueColor(), color1: UIColor.redColor())
                .SIPixellate(scale: 5)
                .toUIImage()

For complex chains of filters, using SIFastChainableImage can be four or fives times faster. However, in this mode, color management is turned off.

Blurring Images

To blur an image you have three options: a true Gaussian blur (SIGaussianBlur), a box blur (SIBoxBlur) and ShinpuruImage fast blur (SIFastBlur) which is based on vImageTentConvolve. Of the three, I've found SIBoxBlur to be the fastest and SIGaussianBlur to be the slowest. It's worth using measureBlock() to do your own performance testing.