Skip to content

Instantly share code, notes, and snippets.

@venkatchm
Last active January 31, 2017 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save venkatchm/36c89806b647d5d40e559c7d8bf2fd78 to your computer and use it in GitHub Desktop.
Save venkatchm/36c89806b647d5d40e559c7d8bf2fd78 to your computer and use it in GitHub Desktop.
static func getCroppedImageUrl(imageUrl: String?, width: CGFloat, height: CGFloat) -> URL? {
guard let _imageUrl = imageUrl else {
return nil
}
do {
let cloudinary = try CLCloudinary(url: Configuration.cloudinaryURL())
let transformation = CLTransformation()
transformation?.width = width
transformation?.height = height
guard let _transformation = transformation else {
return nil
}
let options = ["type": "fetch",
"transformation": _transformation,
"sign_url": "YES",
"secure": true] as [String : Any]
let convertedURL = cloudinary?.url(_imageUrl, options: options)
return URL(string: convertedURL!)
}
catch {
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment