Skip to content

Instantly share code, notes, and snippets.

@zoomacode
zoomacode / input.swift
Created September 3, 2015 19:47 — forked from anonymous/input.swift
Sample with stdin loop reading in swift
func trim(str: String) ->String {
return str.stringByTrimmingCharactersInSet(NSCharacterSet.newlineCharacterSet())
}
func input() -> String? {
var keyboard = NSFileHandle.fileHandleWithStandardInput()
var inputData = keyboard.availableData
var result: String? = nil
if inputData.length != 0 {
result = NSString(data: inputData, encoding:NSUTF8StringEncoding) as? String
import Quartz
import CoreFoundation as CF
import os, sys
filename = os.path.abspath(sys.argv[1])
url = CF.CFURLCreateFromFileSystemRepresentation(None, filename, len(filename), False)
img_src = Quartz.ImageIO.CGImageSourceCreateWithURL(url, {})
properties = Quartz.ImageIO.CGImageSourceCopyPropertiesAtIndex(img_src, 0, None)
exif = properties[Quartz.ImageIO.kCGImagePropertyExifDictionary]