Turn images to ASCII art. UIImage and NSImage extensions included.
ASCIIfy is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "ASCIIfy"
You start by poking around in the included Playground. You can do a basic conversion with just a couple lines:
let font = ASCIIConverter.defaultFont.withSize(24.0)
let outputImage = inputImage?.fy_asciiImageWith(font, colorMode: .color)
Extensions are great. You can also build a reusable ASCIIConverter
object to expose fine-grain controls:
let colorConverter = ASCIIConverter(lut: ColorLookupTable())
colorConverter.font = font
colorConverter.backgroundColor = .black
colorConverter.colorMode = .color
colorConverter.columns = 20
let colorResult = colorConverter.convertImage(flowerImage)
You can even define your own lookup table to control the characters that get used. Take a look at the ColorLookupTable to get started:
let colorConverter = ASCIIConverter(lut: ColorLookupTable())
colorConverter.font = ASCIIConverter.defaultFont.withSize(30.0)
colorConverter.backgroundColor = .black
colorConverter.columns = 30
let colorConverterResult = colorConverter.convertImage(flowerImage)
To run the example iOS and macOS projects, clone the repo, and run pod install
from the Example
directory.
ASCIIfy is a heavily modified fork of BKAsciiImage.
ASCIIfy is available under the MIT license. See the LICENSE file for more info.