{"id":1444,"url":"https://github.com/kean/DFImageManager","last_synced_at":"2025-08-02T04:31:12.943Z","repository":{"id":22668968,"uuid":"26012331","full_name":"kean/DFImageManager","owner":"kean","description":"Image loading, processing, caching and preheating","archived":true,"fork":false,"pushed_at":"2019-11-16T18:13:13.000Z","size":2731,"stargazers_count":1181,"open_issues_count":0,"forks_count":98,"subscribers_count":38,"default_branch":"master","last_synced_at":"2024-11-22T11:22:49.040Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","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/kean.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2014-10-31T10:44:35.000Z","updated_at":"2024-11-12T11:24:51.000Z","dependencies_parsed_at":"2022-08-21T03:20:59.067Z","dependency_job_id":null,"html_url":"https://github.com/kean/DFImageManager","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kean%2FDFImageManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kean%2FDFImageManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kean%2FDFImageManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kean%2FDFImageManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kean","download_url":"https://codeload.github.com/kean/DFImageManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228438911,"owners_count":17920014,"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:46.600Z","updated_at":"2024-12-06T08:31:01.542Z","avatar_url":"https://github.com/kean.png","language":"Objective-C","funding_links":[],"categories":["Media","\u003e 1k ★","Objective-C","UI"],"sub_categories":["Image","Other free courses"],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://cloud.githubusercontent.com/assets/1567433/9706439/4d3fd63c-54ed-11e5-91ec-a52c768b67fe.png\" width=\"70%\"/\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://cocoapods.org\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/v/DFImageManager.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Carthage/Carthage\"\u003e\u003cimg src=\"https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nAdvanced framework for loading, caching, processing, displaying and preheating images.\n\n**This framework is no longer maintained.**\n\n**Programming in Swift? Check out [Nuke](https://github.com/kean/Nuke)!**\n\n## \u003ca name=\"h_features\"\u003e\u003c/a\u003eFeatures\n\n- Zero config\n- Works great with both Objective-C and Swift\n- Performant, asynchronous, thread safe\n\n##### Loading\n- Uses [NSURLSession](https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSURLSession_class/) with [HTTP/2](https://en.wikipedia.org/wiki/HTTP/2) support\n- Optional [AFNetworking](#installation) integration, combine the power of both frameworks!\n- Uses a single fetch operation for equivalent requests\n- [Intelligent preheating](https://github.com/kean/DFImageManager/wiki/Image-Preheating-Guide) of images close to the viewport\n\n##### Caching\n- Doesn't reinvent caching, relies on [HTTP cache](https://tools.ietf.org/html/rfc7234) and its implementation in [Foundation](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html)\n- Caching is completely transparent to the client\n- Two cache layers, including [top level memory cache](https://github.com/kean/DFImageManager/wiki/Image-Caching-Guide) for decompressed images\n\n##### Processing\n- Optional [FLAnimatedImage](https://github.com/Flipboard/FLAnimatedImage) integration\n- Optional [WebP](https://developers.google.com/speed/webp/) integration\n- Progressive image decoding including progressive JPEG\n- Background image decompression and scaling in a single step\n- Resize and crop loaded images to [fit displayed size](https://developer.apple.com/library/ios/qa/qa1708/_index.html), add rounded corners or circle\n\n##### Advanced\n- Customize different parts of the framework using dependency injection\n- Create and [compose image managers](https://github.com/kean/DFImageManager/wiki/Extending-Image-Manager-Guide#using-dfcompositeimagemanager) into a tree of responsibility\n\n## \u003ca name=\"h_getting_started\"\u003e\u003c/a\u003eGetting Started\n- Take a look at comprehensive [demo](https://github.com/kean/DFImageManager/tree/master/Demo) using `pod try DFImageManager` command\n- Check out complete [documentation](http://cocoadocs.org/docsets/DFImageManager) and [Wiki](https://github.com/kean/DFImageManager/wiki)\n- [Install](#installation), `@import DFImageManager` and enjoy!\n\n## \u003ca name=\"h_usage\"\u003e\u003c/a\u003eUsage\n\n#### Zero Config\n\n```objective-c\n[[DFImageManager imageTaskForResource:\u003c#imageURL#\u003e completion:^(UIImage *image, NSError *error, DFImageResponse *response, DFImageTask *task){\n    // Use loaded image\n}] resume];\n```\n\n#### Adding Request Options\n\n```objective-c\nDFMutableImageRequestOptions *options = [DFMutableImageRequestOptions new]; // builder\noptions.priority = DFImageRequestPriorityHigh;\noptions.allowsClipping = YES;\n\nDFImageRequest *request = [DFImageRequest requestWithResource:\u003c#imageURL#\u003e targetSize:CGSizeMake(100, 100) contentMode:DFImageContentModeAspectFill options:options.options];\n\n[[DFImageManager imageTaskForRequest:request completion:^(UIImage *image, NSError *error, DFImageResponse *response, DFImageTask *imageTask) {\n    // Image is resized and clipped to fill 100x100px square\n    if (response.isFastResponse) {\n        // Image was returned synchronously from the memory cache\n    }\n}] resume];\n```\n\n#### Using Image Task\n\n```objective-c\nDFImageTask *task = [DFImageManager imageTaskForResource:\u003c#imageURL#\u003e completion:nil];\nNSProgress *progress = task.progress;\ntask.priority = DFImageRequestPriorityHigh; // Change priority of executing task\n[task cancel];\n```\n\n#### Using UI Components\nUse methods from `UIImageView` category for simple cases:\n```objective-c\nUIImageView *imageView = ...;\n[imageView df_setImageWithResource:\u003c#imageURL#\u003e];\n```\n\nUse `DFImageView` for more advanced features:\n```objective-c\nDFImageView *imageView = ...;\nimageView.allowsAnimations = YES; // Animates images when the response wasn't fast enough\nimageView.managesRequestPriorities = YES; // Automatically changes current request priority when image view gets added/removed from the window\n\n[imageView prepareForReuse];\n[imageView setImageWithResource:\u003c#imageURL#\u003e];\n```\n\n#### UICollectionView\n\n```objective-c\n- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {\n    UICollectionViewCell *cell = \u003c#cell#\u003e\n    DFImageView *imageView = (id)[cell viewWithTag:15];\n    if (!imageView) {\n        imageView = [[DFImageView alloc] initWithFrame:cell.bounds];\n        imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;\n        imageView.tag = 15;\n        [cell addSubview:imageView];\n    }\n    [imageView prepareForReuse];\n    [imageView setImageWithResource:\u003c#image_url#\u003e];\n    return cell;\n}\n```\n\nCancel image task as soon as the cell goes offscreen (optional):\n\n```objective-c\n- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {\n    [((DFImageView *)[cell viewWithTag:15]) prepareForReuse];\n}\n```\n\n#### Preheating Images\n\n```objective-c\nNSArray\u003cDFImageRequest *\u003e *requestsForAddedItems = \u003c#requests#\u003e;\n[DFImageManager startPreheatingImagesForRequests:requestsForAddedItems];\n\nNSArray\u003cDFImageRequest *\u003e *requestsForRemovedItems = \u003c#requests#\u003e;\n[DFImageManager stopPreheatingImagesForRequests:requestsForRemovedItems];\n```\n\n#### Progressive Image Decoding\n\n```objective-c\n// Enable progressive image decoding\n[DFImageManagerConfiguration setAllowsProgressiveImage:YES];\n\n// Create image request that allows progressive image\nDFMutableImageRequestOptions *options = [DFMutableImageRequestOptions new];\noptions.allowsProgressiveImage = YES;\nDFImageRequest *request = \u003c#request#\u003e;\n\nDFImageTask *task = \u003c#task#\u003e;\ntask.progressiveImageHandler = ^(UIImage *__nonnull image){\n    imageView.image = image;\n};\n[task resume];\n```\n\n#### Customizing Image Manager\n\n```objective-c\nid\u003cDFImageFetching\u003e fetcher = \u003c#fetcher#\u003e;\nid\u003cDFImageDecoding\u003e decoder = \u003c#decoder#\u003e;\nid\u003cDFImageProcessing\u003e processor = \u003c#processor#\u003e;\nid\u003cDFImageCaching\u003e cache = \u003c#cache#\u003e;\n\nDFImageManagerConfiguration *configuration = [[DFImageManagerConfiguration alloc] initWithFetcher:fetcher];\nconfiguration.decoder = decoder;\nconfiguration.processor = processor;\nconfiguration.cache = cache;\n\n[DFImageManager setSharedManager:[[DFImageManager alloc] initWithConfiguration:configuration]];\n```\n\n#### Composing Image Managers\nThe `DFCompositeImageManager` constructs a [tree of responsibility](https://github.com/kean/DFImageManager/wiki/Extending-Image-Manager-Guide#using-dfcompositeimagemanager) from image managers and dynamically dispatch requests between them. Each manager should conform to `DFImageManaging` protocol. The `DFCompositeImageManager` also conforms to `DFImageManaging` protocol so that individual managers and compositions can be treated uniformly.\n\n```objective-c\nid\u003cDFImageManaging\u003e manager1 = \u003c#manager#\u003e\nid\u003cDFImageManaging\u003e manager2 = \u003c#manager#\u003e\nid\u003cDFImageManaging\u003e composite = [[DFCompositeImageManager alloc] initWithImageManagers:@[manager1, manager2]];\n```\n\n## \u003ca name=\"h_design\"\u003e\u003c/a\u003eDesign\n\n\u003cimg src=\"https://cloud.githubusercontent.com/assets/1567433/9706417/0352d3bc-54ed-11e5-94ff-cb8691800f78.png\" width=\"66%\"/\u003e\n\n|Protocol|Description|\n|--------|-----------|\n|`DFImageManaging`|A high-level API for loading images|\n|`DFImageFetching`|Performs fetching of image data (`NSData`)|\n|`DFImageDecoding`|Converts `NSData` to `UIImage` objects|\n|`DFImageProcessing`|Processes decoded images|\n|`DFImageCaching`|Stores processed images into memory cache|\n\n## Installation\u003ca name=\"installation\"\u003e\u003c/a\u003e\n\n### [CocoaPods](http://cocoapods.org)\n\nTo install DFImageManager add a dependency in your Podfile:\n```ruby\npod 'DFImageManager'\n```\n\nBy default it will install these subspecs:\n- `DFImageManager/Core` - DFImageManager core classes\n- `DFImageManager/UI` - UI components\n\nThere are four more optional subspecs:\n- `DFImageManager/AFNetworking` - replaces networking stack with [AFNetworking](https://github.com/AFNetworking/AFNetworking)\n- `DFImageManager/GIF` - GIF support with a [FLAnimatedImage](https://github.com/Flipboard/FLAnimatedImage) dependency\n- `DFImageManager/WebP` - WebP support with a [libwebp](https://cocoapods.org/pods/libwebp) dependency\n- `DFImageManager/PhotosKit` - Photos Framework support\n\nTo install optional subspecs include them in your Podfile:\n```ruby\npod 'DFImageManager'\npod 'DFImageManager/AFNetworking'\npod 'DFImageManager/GIF'\npod 'DFImageManager/WebP'\npod 'DFImageManager/PhotosKit'\n```\n\n### [Carthage](https://github.com/Carthage/Carthage)\n\n DFImageManager has a limited Carthage support that doesn't feature [FLAnimatedImage](https://github.com/Flipboard/FLAnimatedImage) and [AFNetworking](https://github.com/AFNetworking/AFNetworking) integration. To install DFImageManager add a dependency to your Cartfile:\n```\ngithub \"kean/DFImageManager\"\n```\n\n## \u003ca name=\"h_requirements\"\u003e\u003c/a\u003eRequirements\n- iOS 8.0+ / watchOS 2\n- Xcode 7.0+\n\n## \u003ca name=\"h_supported_image_formats\"\u003e\u003c/a\u003eSupported Image Formats\n- Image formats supported by `UIImage` (JPEG, PNG, BMP, [and more](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/))\n- GIF (`GIF` subspec)\n- WebP (`WebP` subspec)\n\n## \u003ca name=\"h_contribution\"\u003e\u003c/a\u003eContribution\n\n- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/dfimagemanager). (Tag 'dfimagemanager')\n- If you **found a bug**, and can provide steps to reproduce it, open an issue.\n- If you **have a feature request**, open an issue.\n- If you **want to contribute**, branch of the `develop` branch and submit a pull request.\n\n## Contacts\n\n\u003ca href=\"https://github.com/kean\"\u003e\n\u003cimg src=\"https://cloud.githubusercontent.com/assets/1567433/6521218/9c7e2502-c378-11e4-9431-c7255cf39577.png\" height=\"44\" hspace=\"2\"/\u003e\n\u003c/a\u003e\n\u003ca href=\"https://twitter.com/a_grebenyuk\"\u003e\n\u003cimg src=\"https://cloud.githubusercontent.com/assets/1567433/6521243/fb085da4-c378-11e4-973e-1eeeac4b5ba5.png\" height=\"44\" hspace=\"2\"/\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.linkedin.com/pub/alexander-grebenyuk/83/b43/3a0\"\u003e\n\u003cimg src=\"https://cloud.githubusercontent.com/assets/1567433/6521256/20247bc2-c379-11e4-8e9e-417123debb8c.png\" height=\"44\" hspace=\"2\"/\u003e\n\u003c/a\u003e\n\n## License\n\nDFImageManager is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkean%2FDFImageManager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkean%2FDFImageManager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkean%2FDFImageManager/lists"}