Skip to content

Instantly share code, notes, and snippets.

superwhite() { swift - "$1" "${1%.*}-hdr.jpg" <<'SW'
import Foundation; import CoreGraphics; import ImageIO; import UniformTypeIdentifiers
let a = CommandLine.arguments
guard a.count >= 3, let s = CGImageSourceCreateWithURL(URL(fileURLWithPath: a[1]) as CFURL, nil),
let c = CGImageSourceCreateImageAtIndex(s, 0, nil) else { print("usage: superwhite image.png"); exit(1) }
let w = c.width, h = c.height, r = w * 4
var b = [UInt8](repeating: 0, count: r * h)
let x = CGContext(data: &b, width: w, height: h, bitsPerComponent: 8, bytesPerRow: r,
space: CGColorSpace(name: CGColorSpace.sRGB)!, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)!
x.setFillColor(red: 1, green: 1, blue: 1, alpha: 1); x.fill(CGRect(x: 0, y: 0, width: w, height: h))
{
"content": "<p id='footer-signature'>Made with ❤️ by <a href='https://basith.me/'>Basith</a></p>"
}