Skip to content

Instantly share code, notes, and snippets.

@venkatchm
Last active January 31, 2017 06:45
Show Gist options
  • 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 = [CloudinaryConstants.accessType: CloudinaryConstants.fetch,
CloudinaryConstants.transformation: _transformation,
CloudinaryConstants.signURL: CloudinaryConstants.isSignURL,
CloudinaryConstants.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