   }
   
   func resize(path: String) {
+    if !prepareTempDirectory() {
+      return
+    }
+    
     let orgURL = NSURL(fileURLWithPath: path)!
     let toURL = self.toURL(path)
     let ir = ImageResizer(inputScale: self.inputScale, inputAspectRatio: 1.0)

        
        var error: NSErrorPointer = nil
        if !fm.moveItemAtURL(orgURL, toURL: toURL, error: error) {
          fm.removeItemAtURL(tempURL, error: nil)
          return
        }

    }
  }
  
  func prepareTempDirectory() -> Bool {
    let fm = NSFileManager.defaultManager()
    if !fm.fileExistsAtPath(Constants.Path.Temp) {
      if !fm.createDirectoryAtPath(Constants.Path.Temp, withIntermediateDirectories: false, attributes: nil, error: nil) {
        println("Could not create \(Constants.Path.Temp)")
        return false
      }
    }
    
    return true
  }
  
  func copyToTemp(url: NSURL!) -> NSURL? {
    let filename = url.lastPathComponent
    let path = Constants.Path.Temp.stringByAppendingPathComponent(filename!)
    if let toURL = NSURL.fileURLWithPath(path) {
      var error: NSErrorPointer = nil
      if !NSFileManager.defaultManager().copyItemAtURL(url, toURL: toURL, error: error) {
        println("Could not copy to temporary folder. \(error)")
      }
      return toURL
    }
