Skip to content

heestand-xyz/ImageFX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImageFX

Powered by Metal with AsyncGraphics

Install

Swift Package

.package(url: "https://github.com/heestand-xyz/ImageFX", from: "2.0.0")

In version 2.0.0 spatial values are not relative anymore, they are absolute in pixel space

Effects

All examples work with UIImage and NSImage

let image: UIImage = UIImage(named: "Kite")!

Blur

let fxImage: UIImage = try await image.fxBlur(100)

Edge

let fxImage: UIImage = try await image.fxEdge()

Clamp

let fxImage: UIImage = try await image.fxClamp(low: 0.25, high: 0.75)

Kaleidoscope

let fxImage: UIImage = try await image.fxKaleidoscope()

Levels: Brightness

let fxImage: UIImage = try await image.fxBrightness(2.0)

Levels: Gamma

let fxImage: UIImage = try await image.fxGamma(0.5)

Levels: Invert

let fxImage: UIImage = try await image.fxInvert()

Levels: Opacity

let fxImage: UIImage = try await image.fxOpacity(0.5)

Levels: Contrast

let fxImage: UIImage = try await image.fxContrast(2.0)

Quantize

let fxImage: UIImage = try await image.fxQuantize(0.125)

Sharpen

let fxImage: UIImage = try await image.fxSharpen(2.0)

Slope

let fxImage: UIImage = try await image.fxSlope()

Threshold

let fxImage: UIImage = try await image.fxThreshold()

Sepia

let fxImage: UIImage = try await image.fxSepia(color: .orange)

Range

let fxImageA: UIImage = try await image.fxRange(inLow: 0.0, inHigh: 1.0, outLow: 0.0, outHigh: 0.5)

Saturation

let fxImageA: UIImage = try await image.fxSaturation(0.5)
let fxImageB: UIImage = try await image.fxMonochrome()

Hue

let fxImage: UIImage = try await image.fxHue(.degrees(180))

Custom Effects

import AsyncGraphics
let fxImage: UIImage = try await image
    .fx { graphic in
        let noise: Graphic = try await .coloredNoise(resolution: graphic.resolution)
        return try await graphic.displaced(with: noise, offset: 100)
    }