{"id":1467,"url":"https://github.com/kiavashfaisali/KFSwiftImageLoader","last_synced_at":"2025-08-02T04:31:17.904Z","repository":{"id":28904069,"uuid":"32428890","full_name":"kiavashfaisali/KFSwiftImageLoader","owner":"kiavashfaisali","description":"An extremely high-performance, lightweight, and energy-efficient pure Swift async web image loader with memory and disk caching for iOS and  Watch.","archived":false,"fork":false,"pushed_at":"2019-11-29T21:11:15.000Z","size":12780,"stargazers_count":341,"open_issues_count":2,"forks_count":35,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-04-29T22:13:01.588Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kiavashfaisali.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-18T00:42:15.000Z","updated_at":"2024-01-02T05:36:50.000Z","dependencies_parsed_at":"2022-08-02T20:30:10.399Z","dependency_job_id":null,"html_url":"https://github.com/kiavashfaisali/KFSwiftImageLoader","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiavashfaisali%2FKFSwiftImageLoader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiavashfaisali%2FKFSwiftImageLoader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiavashfaisali%2FKFSwiftImageLoader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiavashfaisali%2FKFSwiftImageLoader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiavashfaisali","download_url":"https://codeload.github.com/kiavashfaisali/KFSwiftImageLoader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228438931,"owners_count":17920017,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:15:47.106Z","updated_at":"2024-12-06T08:31:03.741Z","avatar_url":"https://github.com/kiavashfaisali.png","language":"Swift","funding_links":[],"categories":["Media","Swift","UI","Libs"],"sub_categories":["Image","Other free courses","Images"],"readme":"# KFSwiftImageLoader\n\nKFSwiftImageLoader is an extremely high-performance, lightweight, and energy-efficient pure Swift async web image loader with memory and disk caching for iOS and  Watch.\n\nThis is the world's first  Watch-optimized async image loader with WKInterfaceImage extensions and intelligent automatic cache handling via WKInterfaceDevice.\n\nPlease also check out [KFWatchKitAnimations](https://github.com/kiavashfaisali/KFWatchKitAnimations) for a great way to record beautiful 60 FPS animations for  Watch by recording animations from the iOS Simulator.\n\nNote:\n-----\n## Features\n* WKInterfaceImage, UIImageView, UIButton, and MKAnnotationView extensions for asynchronous web image loading.\n* Memory and disk cache to prevent downloading images every time a request is made or when the app relaunches, with automatic cache management to optimize resource use.\n* Energy efficiency by sending only one HTTP/HTTPS request for image downloads from multiple sources that reference the same URL string, registering them as observers for the request.\n* Maximum peformance by utilizing the latest and greatest of modern technologies such as Swift 5.1, URLSession, and GCD.\n\n## KFSwiftImageLoader Requirements\n* Xcode 11.0+\n* iOS 12.0+\n* watchOS 6.0+\n\n## CocoaPods\nTo ensure you stay up-to-date with the latest version of KFSwiftImageLoader, it is recommended that you use CocoaPods.\n\nOptimized for CocoaPods 1.8.4+, so you will need to run the following command first:\n``` bash\nsudo gem install cocoapods\n```\n\nAdd the following to your Podfile\n``` bash\nplatform :ios, '12.0'\n\npod 'KFSwiftImageLoader', '~\u003e 4.0'\n```\n\nYou will need to import KFSwiftImageLoader everywhere you wish to use it:\n``` swift\nimport KFSwiftImageLoader\n```\n\n## Example Usage\n### UIImageView\n``` swift\nimageView.loadImage(urlString: urlString)\n```\n\nYes, it really is that easy. It just works.\nIn the above example, the inputs \"placeholder\" and \"completion\" were ignored, so they default to nil.\nWe can include them in the following way:\n``` swift\nimageView.loadImage(urlString: urlString, placeholder: UIImage(named: \"KiavashFaisali\")) {\n    (success, error) in\n    \n    // 'success' is a 'Bool' indicating success or failure.\n    // 'error' is an 'Error?' containing the error (if any) when 'success' is 'false'.\n}\n```\n\nFor flexibility, there are several different methods for loading images.\nBelow are the method signatures for all of them:\n``` swift\nfunc loadImage(_ urlString: String,\n               placeholder: UIImage? = nil,\n                completion: ((_ success: Bool, _ error: Error?) -\u003e Void)? = nil)\n\nfunc loadImage(_ url: URL,\n         placeholder: UIImage? = nil,\n          completion: ((_ success: Bool, _ error: Error?) -\u003e Void)? = nil)\n\nfunc loadImage(_ request: URLRequest,\n             placeholder: UIImage? = nil,\n              completion: ((_ success: Bool, _ error: Error?) -\u003e Void)? = nil)\n```\n\n### WKInterfaceImage\n``` swift\nfunc loadImage(_ urlString: urlString,\n           placeholderName: String? = nil,\n                completion: ((_ success: Bool, _ error: Error?) -\u003e Void)? = nil)\n```\n\nThe main difference with the UIImageView extension is the parameter \"placeholderName\", which requires the placeholder image to be bundled with the  Watch app for performance reasons.\n\n### UIButton\n``` swift\nbutton.loadImage(urlString)\n```\n\nAgain, KFSwiftImageLoader makes it very easy to load images.\nIn this case, the button uses mostly the same method signature as UIImageView, but it includes two more optional parameters: \"isBackground\" and \"controlState\".\n\n``` swift\nfunc loadImage(_ urlString: String,\n               placeholder: UIImage? = nil,\n              controlState: UIControlState = .normal,\n              isBackground: Bool = false,\n                completion: ((_ success: Bool, _ error: Error?) -\u003e Void)? = nil)\n```\n\n\"controlState\" takes a UIControlState value that is required when setting images for buttons.\n\"isBackground\" simply indicates whether or not the button should use \"setBackgroundImage:for:\" or \"setImage:for:\" for image loading.\n\n### MKAnnotationView\n``` swift\nannotationView.loadImage(urlString)\n```\n\nThe methods in the MKAnnotationView extension are exactly the same as those in the UIImageView extension.\n\n### KFImageCacheManager\n``` swift\n// Disable the fade animation.\n// The default value is 0.1.\nKFImageCacheManager.shared.fadeAnimationDuration = 0.0\n\n// Set a custom timeout interval for the image requests.\n// The default value is 60.0.\nKFImageCacheManager.shared.timeoutIntervalForRequest = 15.0\n\n// Set a custom request cache policy for the image requests as well as the session's configuration.\n// The default value is .returnCacheDataElseLoad.\nKFImageCacheManager.shared.requestCachePolicy = .useProtocolCachePolicy\n\n// Disable file system caching by adjusting the max age of the disk cache and the request cache policy.\n// The default value is 60 * 60 * 24 * 7 = 604800 seconds (1 week).\nKFImageCacheManager.shared.diskCacheMaxAge = 0\nKFImageCacheManager.shared.requestCachePolicy = .reloadIgnoringLocalCacheData\n```\n\n## Sample App\nPlease take a look at the sample app under the Example folder for a clear idea of how to use KFSwiftImageLoader to load images in iOS and  Watch.\n\n## Contact Information\nKiavash Faisali\n- https://github.com/kiavashfaisali\n- kiavashfaisali@outlook.com\n\n## License\nKFSwiftImageLoader is available under the MIT license.\n\nCopyright (c) 2019 Kiavash Faisali\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiavashfaisali%2FKFSwiftImageLoader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiavashfaisali%2FKFSwiftImageLoader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiavashfaisali%2FKFSwiftImageLoader/lists"}