Last active
January 31, 2017 06:45
-
-
Save venkatchm/36c89806b647d5d40e559c7d8bf2fd78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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