इस प्रोजेक्ट के बारे में
Kingfisher वेब से छवियों को डाउनलोड और कैश करने के लिए एक शक्तिशाली, शुद्ध-Swift लाइब्रेरी है। यह आपके अगले ऐप में रिमोट छवियों के साथ काम करने का एक शुद्ध-Swift तरीका प्रदान करता है।
## विशेषताएँ
- असिंक्रोनस छवि डाउनलोडिंग और कैशिंग।
- URLSession-आधारित नेटवर्किंग या स्थानीय रूप से प्रदान किए गए डेटा से छवियाँ लोड करना।
- उपयोगी छवि प्रोसेसर और फ़िल्टर प्रदान किए गए।
- मेमोरी और डिस्क दोनों के लिए बहु-स्तरीय हाइब्रिड कैश।
- कस्टमाइज़ करने योग्य समाप्ति तिथि और आकार सीमा के साथ कैश व्यवहार पर बारीक नियंत्रण।
- डिस्क कैश जाँचों पर कॉलर थ्रेड को ब्लॉक करने से बचने के लिए KingfisherManager में ऑप्ट-इन असिंक कैश प्रोबिंग।
- प्रदर्शन सुधारने के लिए रद्द करने योग्य डाउनलोडिंग और पहले डाउनलोड की गई सामग्री का स्वतः पुनः उपयोग।
- स्वतंत्र घटक: आवश्यकतानुसार डाउनलोडर, कैशिंग सिस्टम और छवि प्रोसेसर को अलग-अलग उपयोग करें।
- छवियों को प्रीफ़ेच करना और कैश से उन्हें दिखाकर अपने ऐप को बूस्ट करना।
- UIImageView, NSImageView, NSButton, UIButton, NSTextAttachment, WKInterfaceImage, TVMonogramView, और CPListItem के लिए एक्सटेंशन, ताकि URL से सीधे छवि सेट की जा सके।
- छवियाँ सेट करते समय अंतर्निहित ट्रांज़िशन एनिमेशन।
- छवियाँ लोड करते समय कस्टमाइज़ करने योग्य प्लेसहोल्डर और इंडिकेटर।
- आसानी से विस्तारणीय छवि प्रसंस्करण और छवि प्रारूप।
- Low Data Mode समर्थन।
- SwiftUI समर्थन।
- Swift 6 और Swift Concurrency (strict mode) के लिए तैयार।
- Live Photo के लिए लोड और कैश।
## Kingfisher 101
सबसे सरल उपयोग-मामला UIImageView एक्सटेंशन के साथ एक इमेज व्यू पर छवि सेट करना है:
```swift
import Kingfisher
let url = URL(string: "https://example.com/image.png")
imageView.kf.setImage(with: url)
```
Kingfisher url से छवि डाउनलोड करेगा, उसे मेमोरी कैश और डिस्क कैश दोनों में भेजेगा, और imageView में प्रदर्शित करेगा। जब आप बाद में उसी URL के साथ इसे सेट करेंगे, तो छवि कैश से प्राप्त होकर तुरंत दिखाई देगी।
यह तब भी काम करता है जब आप SwiftUI का उपयोग करते हैं:
```swift
var body: some View {
KFImage(URL(string: "https://example.com/image.png")!)
}
```
## एक अधिक उन्नत उदाहरण
शक्तिशाली विकल्पों के साथ, आप Kingfisher में कठिन कार्यों को सरल तरीके से कर सकते हैं। उदाहरण के लिए, नीचे दिया गया कोड:
1. एक उच्च-रिज़ॉल्यूशन छवि डाउनलोड करता है।
2. छवि व्यू के आकार से मेल खाने के लिए उसे डाउनसैंपल करता है।
3. दिए गए रेडियस के साथ उसे गोल कोनों वाला बनाता है।
4. डाउनलोड करते समय एक सिस्टम इंडिकेटर और प्लेसहोल्डर छवि दिखाता है।
5. तैयार होने पर, छोटी थंबनेल छवि को "fade in" प्रभाव के साथ एनिमेट करता है।
6. मूल बड़ी छवि को बाद में उपयोग के लिए डिस्क पर भी कैश किया जाता है, ताकि डिटेल व्यू में उसे फिर से डाउनलोड न करना पड़े।
7. कार्य समाप्त होने पर, सफलता या विफलता के लिए कंसोल लॉग प्रिंट होता है।
```swift
let url = URL(string: "https://example.com/high_resolution_image.png")
let processor = DownsamplingImageProcessor(size: imageView.bounds.size)
|> RoundCornerImageProcessor(cornerRadius: 20)
imageView.kf.indicatorType = .activity
imageView.kf.setImage(
with: url,
placeholder: UIImage(named: "placeholderImage"),
options: [
.processor(processor),
.scaleFactor(UIScreen.main.scale),
.transition(.fade(1)),
.cacheOriginalImage
])
{
result in
switch result {
case .success(let value):
print("Task done for: \(value.source.url?.absoluteString ?? "")")
case .failure(let error):
print("Job failed: \(error.localizedDescription)")
}
}
```
यह मेरे दैनिक काम में आने वाली एक सामान्य स्थिति है। सोचिए, Kingfisher के बिना आपको कितनी पंक्तियाँ लिखनी पड़ेंगी!
## Method Chaining
यदि आप kf एक्सटेंशन के प्रशंसक नहीं हैं, तो आप KF builder का उपयोग करके मेथड इनवोकेशन को चेन भी कर सकते हैं। नीचे दिया गया कोड वही काम कर रहा है:
```swift
// Use `kf` extension
imageView.kf.setImage(
with: url,
placeholder: placeholderImage,
options: [
.processor(processor),
.loadDiskFileSynchronously,
.cacheOriginalImage,
.transition(.fade(0.25)),
.lowDataMode(.network(lowResolutionURL))
],
progressBlock: { receivedSize, totalSize in
// Progress updated
},
completionHandler: { result in
// Done
}
)
// Use `KF` builder
KF.url(url)
.placeholder(placeholderImage)
.setProcessor(processor)
.loadDiskFileSynchronously()
.cacheMemoryOnly()
.fade(duration: 0.25)
.lowDataModeSource(.network(lowResolutionURL))
.onProgress { receivedSize, totalSize in }
.onSuccess { result in }
.onFailure { error in }
.set(to: imageView)
```
और इससे भी बेहतर, यदि बाद में आप SwiftUI पर स्विच करना चाहते हैं, तो ऊपर दिए गए KF को KFImage में बदल दें, और आपका काम हो गया:
```swift
struct ContentView: View {
var body: some View {
KFImage.url(url)
.placeholder(placeholderImage)
.setProcessor(processor)
.loadDiskFileSynchronously()
.cacheMemoryOnly()
.fade(duration: 0.25)
.lowDataModeSource(.network(lowResolutionURL))
.onProgress { receivedSize, totalSize in }
.onSuccess { result in }
.onFailure { error in }
}
}
```
## आवश्यकताएँ
### वर्तमान डेवलपमेंट ब्रांच
- iOS 15.0+ / macOS 12.0+ / tvOS 15.0+ / watchOS 9.0+ / visionOS 1.0+
- Xcode 26.0+ / Swift 6.2+ कंपाइलर
### Kingfisher 8.0
- (UIKit/AppKit) iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+ / visionOS 1.0+
- (SwiftUI) iOS 14.0+ / macOS 11.0+ / tvOS 14.0+ / watchOS 7.0+ / visionOS 1.0+
- Swift 5.9+
### Kingfisher 7.0
- (UIKit/AppKit) iOS 12.0+ / macOS 10.14+ / tvOS 12.0+ / watchOS 5.0+ / visionOS 1.0+
- (SwiftUI) iOS 14.0+ / macOS 11.0+ / tvOS 14.0+ / watchOS 7.0+ / visionOS 1.0+
- Swift 5.0+
## इंस्टॉलेशन
फ्रेमवर्क को इंस्टॉल और उपयोग करने के लिए निम्नलिखित ट्यूटोरियल्स में से किसी एक को देखें:
- [UIKit Tutorial](https://swiftpackageindex.com/onevcat/kingfisher/master/tutorials/kingfisher/gettingstarteduikit)
- [SwiftUI Tutorial](https://swiftpackageindex.com/onevcat/kingfisher/master/tutorials/kingfisher/gettingstartedswiftui)
वैकल्पिक रूप से, आप नीचे दिए गए तरीकों में से किसी एक का पालन कर सकते हैं।
### Swift Package Manager
- File > Swift Packages > Add Package Dependency
- `https://github.com/onevcat/Kingfisher.git` जोड़ें
- "Up to Next Major" के साथ "8.0.0" चुनें
### CocoaPods
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '13.0'
use_frameworks!
target 'MyApp' do
pod 'Kingfisher', '~> 8.0'
end
```
### Pre-built Framework
1. रिलीज़ पेज खोलें, assets सेक्शन से Kingfisher का नवीनतम संस्करण डाउनलोड करें।
2. `Kingfisher.xcframework` को अपने प्रोजेक्ट में ड्रैग करें और इसे टार्गेट (आमतौर पर ऐप टार्गेट) में जोड़ें।
3. अपना टार्गेट चुनें, "General" टैब में, "Frameworks, Libraries, and Embedded Content" सेक्शन खोजें, Kingfisher के लिए `Embed Without Signing` सेट करें।
## दस्तावेज़ीकरण
दस्तावेज़ीकरण और ट्यूटोरियल देखें:
- [Documentation Home](https://swiftpackageindex.com/onevcat/kingfisher/master/documentation/kingfisher)
- [Getting Started](https://swiftpackageindex.com/onevcat/kingfisher/master/documentation/kingfisher/gettingstarted)
- [UIKit Tutorial](https://swiftpackageindex.com/onevcat/kingfisher/master/tutorials/kingfisher/gettingstarteduikit)
- [SwiftUI Tutorial](https://swiftpackageindex.com/onevcat/kingfisher/master/tutorials/kingfisher/gettingstartedswiftui)
- [Common Tasks - General](https://swiftpackageindex.com/onevcat/kingfisher/master/documentation/kingfisher/commontasks)
- [Common Tasks - Cache](https://swiftpackageindex.com/onevcat/kingfisher/master/documentation/kingfisher/commontasks_cache)
- [Common Tasks - Downloader](https://swiftpackageindex.com/onevcat/kingfisher/master/documentation/kingfisher/commontasks_downloader)
- [Common tasks - Processor](https://swiftpackageindex.com/onevcat/kingfisher/master/documentation/kingfisher/commontasks_processor)
### माइग्रेट करना
- [Kingfisher 8.0 Migration](https://swiftpackageindex.com/onevcat/kingfisher/master/documentation/kingfisher/migration-to-8)
- [Kingfisher 7.0 Migration](https://github.com/onevcat/Kingfisher/wiki/Kingfisher-7.0-Migration-Guide)
यदि आप इससे भी पुराना संस्करण उपयोग कर रहे हैं, तो माइग्रेट करने के चरणों को जानने के लिए नीचे दिए गए गाइड देखें।
## अन्य
### Kingfisher का भविष्य
मैं Kingfisher को हल्का बनाए रखना चाहता हूँ। यह फ्रेमवर्क छवियों को डाउनलोड और कैश करने के लिए एक सरल समाधान प्रदान करने पर केंद्रित है। इसका मतलब यह नहीं है कि फ्रेमवर्क को बेहतर नहीं बनाया जा सकता। Kingfisher पूर्णता से बहुत दूर है, इसलिए इसे बेहतर बनाने के लिए आवश्यक और उपयोगी अपडेट किए जाएंगे।
### विकास और परीक्षण
किसी भी योगदान और पुल रिक्वेस्ट का हार्दिक स्वागत है। हालाँकि, कुछ सुविधाएँ लागू करने या किसी अनिश्चित समस्या को ठीक करने की योजना बनाने से पहले, पहले एक चर्चा खोलने की सलाह दी जाती है। यह अच्छा होगा यदि आपकी पुल रिक्वेस्ट सभी टेस्ट पास करके बिल्ड हो सके। :)
### लोगो के बारे में
Kingfisher का लोगो Tangram (七巧板) से प्रेरित है, जो चीन से सात सपाट आकृतियों से बना एक डिसेक्शन पज़ल है। मेरा मानना है कि वह एक swift नहीं बल्कि kingfisher पक्षी है, लेकिन कुछ लोग ज़ोर देते हैं कि वह एक कबूतर है। मुझे लगता है कि मुझे उसे एक नाम देना चाहिए। अरे दोस्तों, क्या आपके पास कोई सुझाव है?
### संपर्क
Twitter या Sina Weibo पर मुझे फॉलो करें और संपर्क करें। यदि आपको कोई समस्या मिलती है, तो टिकट खोलें। पुल रिक्वेस्ट का भी हार्दिक स्वागत है।
## Backers और Sponsors
ओपन-सोर्स प्रोजेक्ट आपकी मदद के बिना लंबे समय तक जीवित नहीं रह सकते। यदि आपको Kingfisher उपयोगी लगता है, तो कृपया sponsor बनकर इस प्रोजेक्ट का समर्थन करने पर विचार करें। आपका यूज़र आइकन या कंपनी लोगो मेरे ब्लॉग पर आपके होम पेज के लिंक के साथ दिखाई देगा।
GitHub Sponsors के माध्यम से sponsor बनें। :heart:
imgly और emergetools को विशेष धन्यवाद।
### लाइसेंस
Kingfisher MIT लाइसेंस के अंतर्गत जारी किया गया है। विवरण के लिए LICENSE देखें।
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.