{"id":13685970,"url":"https://github.com/zhangao0086/DKImagePickerController","last_synced_at":"2025-05-01T04:33:11.944Z","repository":{"id":21490786,"uuid":"24809655","full_name":"zhangao0086/DKImagePickerController","owner":"zhangao0086","description":"Image Picker Controller for iOS written in Swift 4 \u0026 5.","archived":false,"fork":false,"pushed_at":"2024-05-07T05:41:43.000Z","size":19384,"stargazers_count":1493,"open_issues_count":96,"forks_count":471,"subscribers_count":38,"default_branch":"develop","last_synced_at":"2024-11-04T16:49:51.942Z","etag":null,"topics":["picker","swift"],"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/zhangao0086.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-10-05T06:00:56.000Z","updated_at":"2024-11-01T09:05:00.000Z","dependencies_parsed_at":"2024-05-07T06:41:54.068Z","dependency_job_id":null,"html_url":"https://github.com/zhangao0086/DKImagePickerController","commit_stats":{"total_commits":930,"total_committers":67,"mean_commits":"13.880597014925373","dds":0.1602150537634408,"last_synced_commit":"0bdfeacefa308545adde07bef86e349186335915"},"previous_names":[],"tags_count":86,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangao0086%2FDKImagePickerController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangao0086%2FDKImagePickerController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangao0086%2FDKImagePickerController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangao0086%2FDKImagePickerController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhangao0086","download_url":"https://codeload.github.com/zhangao0086/DKImagePickerController/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223783213,"owners_count":17201913,"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":["picker","swift"],"created_at":"2024-08-02T14:01:00.193Z","updated_at":"2024-11-12T07:32:26.302Z","avatar_url":"https://github.com/zhangao0086.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"DKImagePickerController\n=======================\n\n [![Build Status](https://secure.travis-ci.org/zhangao0086/DKImagePickerController.svg)](http://travis-ci.org/zhangao0086/DKImagePickerController) [![Version Status](http://img.shields.io/cocoapods/v/DKImagePickerController.png)][docsLink] [![license MIT](https://img.shields.io/cocoapods/l/DKImagePickerController.svg?style=flat)][mitLink] [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\n\u003cimg width=\"50%\" height=\"50%\" src=\"https://raw.githubusercontent.com/zhangao0086/DKImagePickerController/develop/Screenshot3.png\" /\u003e\u003cimg width=\"50%\" height=\"50%\" src=\"https://raw.githubusercontent.com/zhangao0086/DKImagePickerController/develop/Screenshot4.png\" /\u003e\n---\n\u003cimg width=\"50%\" height=\"50%\" src=\"https://raw.githubusercontent.com/zhangao0086/DKImagePickerController/develop/Screenshot11.png\" /\u003e\u003cimg width=\"50%\" height=\"50%\" src=\"https://raw.githubusercontent.com/zhangao0086/DKImagePickerController/develop/Screenshot6.png\" /\u003e\n---\n\n## Description\n`DKImagePickerController` is a highly customizable, Pure-Swift library.\n\n### Features\n* Supports both single and multiple selection.\n* Supports filtering albums and sorting by type.\n* Supports landscape, iPad, and orientation switching.\n* iCloud Support.\n* Supports batch exports `PHAsset` to lcoal files.\n* Inline mode Support.\n* Customizable `UICollectionViewLayout`.\n* Customizable `camera`, `photo gallery` and `photo editor`.\n* Dark Mode Support\n\n## Requirements\n* iOS 9.0+ (Drop support for iOS 8 in 4.3.0 or above)\n* ARC\n* Swift 4 \u0026 5\n\n## Installation\n### CocoaPods\n#### iOS 9 and newer\nDKImagePickerController is available on CocoaPods. Simply add the following line to your podfile:\n\n```\n# For latest release in cocoapods\npod 'DKImagePickerController'\n```\n\n#### For Swift 4.1\n```\npod 'DKImagePickerController', :git =\u003e 'https://github.com/zhangao0086/DKImagePickerController.git', :branch =\u003e 'Swift4'\n```\n\n#### For iOS 8\n\n```\npod 'DKImagePickerController', :git =\u003e 'https://github.com/zhangao0086/DKImagePickerController.git', :branch =\u003e 'iOS8'\n```\n\n#### Subspecs\n\nThere are 7 subspecs available now: \n\n| Subspec | Description |\n|---|---|\n| Core | Required. |\n| ImageDataManager | Required. The subspec provides data to `DKImagePickerController`. |\n|   Resource | Required. The subspec provides resource management and internationalization. |\n| PhotoGallery | Optional. The subspec provides preview feature for PHAsset. |\n| Camera | Optional. The subspec provides camera feature. |\n| InlineCamera | Optional. The subspec should be pushed by `UINavigationController`, like `UIImagePickerController` with `UIImagePickerControllerSourceType.camera`. |\n| PhotoEditor | Optional. The subspec provides basic image editing features. |\n\nThis means you can install only some of the `DKImagePickerController` modules. By default, you get all subspecs.  \nIf you need to use your own photo editor, simply specify subspecs other than `PhotoEditor`:\n\n```ruby\npod 'DKImagePickerController', :subspecs =\u003e ['PhotoGallery', 'Camera', 'InlineCamera']\n```\n\nMore information, see [Extensions](#extensions).\n\n### Carthage\n\n```\ngithub \"zhangao0086/DKImagePickerController\"\n```\n\nIf you use Carthage to build your dependencies, make sure you have added `CropViewController.framework`, `DKCamera.framework`, `DKImagePickerController.framework`, `DKPhotoGallery.framework` and `SDWebImage.framework` to the _\"Linked Frameworks and Libraries\"_ section of your target, and have included them in your Carthage framework copying build phase.\n\n## Getting Started\n#### Initialization and presentation\n```swift\n\nlet pickerController = DKImagePickerController()\n\npickerController.didSelectAssets = { (assets: [DKAsset]) in\n    print(\"didSelectAssets\")\n    print(assets)\n}\n\nself.presentViewController(pickerController, animated: true) {}\n\n​````\n\n#### Configurations\n\n​```swift\n /// Use UIDelegate to Customize the picker UI.\n @objc public var UIDelegate: DKImagePickerControllerBaseUIDelegate!\n \n /// Forces deselect of previous selected image. allowSwipeToSelect will be ignored.\n @objc public var singleSelect = false\n \n /// Auto close picker on single select\n @objc public var autoCloseOnSingleSelect = true\n \n /// The maximum count of assets which the user will be able to select, a value of 0 means no limit.\n @objc public var maxSelectableCount = 0\n \n /// Photos will be tagged with the location where they are taken.\n /// If true, your Info.plist should include the \"Privacy - Location XXX\" tag.\n open var containsGPSInMetadata = false\n \n /// Set the defaultAssetGroup to specify which album is the default asset group.\n public var defaultAssetGroup: PHAssetCollectionSubtype?\n \n /// Allow swipe to select images.\n @objc public var allowSwipeToSelect: Bool = false\n \n /// Allow select all\n @objc public var allowSelectAll: Bool = false\n \n /// A Bool value indicating whether the inline mode is enabled.\n @objc public var inline: Bool = false\n \n /// The type of picker interface to be displayed by the controller.\n @objc public var assetType: DKImagePickerControllerAssetType = .allAssets\n \n /// If sourceType is Camera will cause the assetType \u0026 maxSelectableCount \u0026 allowMultipleTypes \u0026 defaultSelectedAssets to be ignored.\n @objc public var sourceType: DKImagePickerControllerSourceType = .both\n \n /// A Bool value indicating whether allows to select photos and videos at the same time.\n @objc public var allowMultipleTypes = true\n \n /// A Bool value indicating whether to allow the picker auto-rotate the screen.\n @objc public var allowsLandscape = false\n \n /// Set the showsEmptyAlbums to specify whether or not the empty albums is shown in the picker.\n @objc public var showsEmptyAlbums = true\n \n /// A Bool value indicating whether to allow the picker shows the cancel button.\n @objc public var showsCancelButton = false\n \n /// The block is executed when the user presses the cancel button.\n @objc public var didCancel: (() -\u003e Void)?\n \n /// The block is executed when the user presses the select button.\n @objc public var didSelectAssets: ((_ assets: [DKAsset]) -\u003e Void)?\n \n /// The block is executed when the number of selected assets is changed.\n @objc public var selectedChanged: (() -\u003e Void)?\n \n /// A Bool value indicating whether to allow the picker to auto-export the selected assets to the specified directory when done is called.\n /// picker will creating a default exporter if exportsWhenCompleted is true and the exporter is nil.\n @objc public var exportsWhenCompleted = false\n \n @objc public var exporter: DKImageAssetExporter?\n \n /// Indicates the status of the exporter.\n @objc public private(set) var exportStatus = DKImagePickerControllerExportStatus.none {\n    willSet {\n        if self.exportStatus != newValue {\n            self.willChangeValue(forKey: #keyPath(DKImagePickerController.exportStatus))\n        }\n    }\n    \n    didSet {\n        if self.exportStatus != oldValue {\n            self.didChangeValue(forKey: #keyPath(DKImagePickerController.exportStatus))\n            \n            self.exportStatusChanged?(self.exportStatus)\n        }\n    }\n }\n \n /// The block is executed when the exportStatus is changed.\n @objc public var exportStatusChanged: ((DKImagePickerControllerExportStatus) -\u003e Void)?\n \n /// The object that acts as the data source of the picker.\n @objc public private(set) lazy var groupDataManager: DKImageGroupDataManager\n\n```\n\n## Inline Mode\n\n\u003cimg width=\"30%\" height=\"30%\" src=\"https://raw.githubusercontent.com/zhangao0086/DKImagePickerController/develop/Screenshot11.png\" /\u003e\n\n```swift\nlet groupDataManagerConfiguration = DKImageGroupDataManagerConfiguration()\ngroupDataManagerConfiguration.fetchLimit = 10\ngroupDataManagerConfiguration.assetGroupTypes = [.smartAlbumUserLibrary]\n\nlet groupDataManager = DKImageGroupDataManager(configuration: groupDataManagerConfiguration)\n\nself.pickerController = DKImagePickerController(groupDataManager: groupDataManager)\npickerController.inline = true\npickerController.UIDelegate = CustomInlineLayoutUIDelegate(imagePickerController: pickerController)\npickerController.assetType = .allPhotos\npickerController.sourceType = .photo\n\nlet pickerView = self.pickerController.view!\npickerView.frame = CGRect(x: 0, y: 170, width: self.view.bounds.width, height: 200)\nself.view.addSubview(pickerView)\n```\n\n## Customizable UI\n\n\u003cimg width=\"30%\" height=\"30%\" src=\"https://raw.githubusercontent.com/zhangao0086/DKImagePickerController/develop/Screenshot6.png\" /\u003e\n\nFor example, see [CustomUIDelegate](https://github.com/zhangao0086/DKImagePickerController/tree/develop/Example/DKImagePickerControllerDemo/CustomUIDelegate).\n\n## Customizable Layout\n\n\u003cimg width=\"30%\" height=\"30%\" src=\"https://raw.githubusercontent.com/zhangao0086/DKImagePickerController/develop/Screenshot10.png\" /\u003e\n\nFor example, see [CustomLayoutUIDelegate](https://github.com/zhangao0086/DKImagePickerController/tree/develop/Example/DKImagePickerControllerDemo/CustomLayoutUIDelegate).\n\n### Conforms UIAppearance protocol\n\n\u003cimg width=\"30%\" height=\"30%\" src=\"https://raw.githubusercontent.com/zhangao0086/DKImagePickerController/develop/Screenshot9.png\" /\u003e\n\nYou can easily customize the appearance of the navigation bar using the appearance proxy.\n```swift\nUINavigationBar.appearance().titleTextAttributes = [\n    NSFontAttributeName : UIFont(name: \"Optima-BoldItalic\", size: 21)!,\n    NSForegroundColorAttributeName : UIColor.redColor()\n]\n```\n\n## Exporting to file\n\nBy default, the picker uses a singleton object of `DKImageAssetExporter` to export `DKAsset` to local files.\n\n```swift\n/*\n Configuration options for a DKImageAssetExporter.  When an exporter is created,\n a copy of the configuration object is made - you cannot modify the configuration\n of an exporter after it has been created.\n */\n@objc\npublic class DKImageAssetExporterConfiguration: NSObject, NSCopying {\n    \n    @objc public var imageExportPreset = DKImageExportPresent.compatible\n    \n    /// videoExportPreset can be used to specify the transcoding quality for videos (via a AVAssetExportPreset* string).\n    @objc public var videoExportPreset = AVAssetExportPresetHighestQuality\n    \n    #if swift(\u003e=4.0)\n    @objc public var avOutputFileType = AVFileType.mov\n    #else\n    @objc public var avOutputFileType = AVFileTypeQuickTimeMovie\n    #endif\n    \n    @objc public var exportDirectory = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(\"DKImageAssetExporter\")\n}\n\n/*\n A DKImageAssetExporter object exports DKAsset(PHAsset) from album (or iCloud) to the app's tmp directory (by default).\n It automatically deletes the exported directories when it receives a UIApplicationWillTerminate notification.\n */\n@objc\nopen class DKImageAssetExporter: DKBaseManager {\n    \n    /// This method starts an asynchronous export operation of a batch of asset.\n    @discardableResult\n    @objc public func exportAssetsAsynchronously(assets: [DKAsset], completion: ((_ info: [AnyHashable : Any]) -\u003e Void)?) -\u003e DKImageAssetExportRequestID\n}\n```\n\nThis exporter can automatically convert HEIF to JPEG:\n\n```swift\n@objc\npublic enum DKImageExportPresent: Int {\n    case\n    compatible, // A preset for converting HEIF formatted images to JPEG.\n    current     // A preset for passing image data as-is to the client.\n}\n```\n\nYou also can observe the export progress of each asset:\n\n```swift\n@objc\npublic protocol DKImageAssetExporterObserver {\n    \n    @objc optional func exporterWillBeginExporting(exporter: DKImageAssetExporter, asset: DKAsset)\n    \n    /// The progress can be obtained from the DKAsset.\n    @objc optional func exporterDidUpdateProgress(exporter: DKImageAssetExporter, asset: DKAsset)\n    \n    /// When the asset's error is not nil, it indicates that an error occurred while exporting.\n    @objc optional func exporterDidEndExporting(exporter: DKImageAssetExporter, asset: DKAsset)\n}\n\nextension DKAsset {\n    \n    /// The exported file will be placed in this location.\n    /// All exported files can be automatically cleaned by the DKImageAssetDiskPurger when appropriate.\n    @objc public var localTemporaryPath: URL?\n    \n    @objc public var fileName: String?\n    \n    /// Indicates the file's size in bytes.\n    @objc public var fileSize: UInt\n        \n    /// If you export an asset whose data is not on the local device, and you have enabled downloading with the isNetworkAccessAllowed property, the progress indicates the progress of the download. A value of 0.0 indicates that the download has just started, and a value of 1.0 indicates the download is complete.\n    @objc public var progress: Double\n    \n    /// Describes the error that occurred if the export has failed or been cancelled.\n    @objc public var error: Error?\n}\n```\n\nFor example, see `Export automatically` and `Export manually`.\n\n## Extensions\nThis picker uses `DKImageExtensionController` manages all extensions, you can register it with a `DKImageBaseExtension` and a specified `DKImageExtensionType` to customize `camera`, `photo gallery` and `photo editor`:\n\n```swift\n/// Registers an extension for the specified type.\npublic class func registerExtension(extensionClass: DKImageBaseExtension.Type, for type: DKImageExtensionType)\n\npublic class func unregisterExtension(for type: DKImageExtensionType)\n```\n\nThe `perform` function will be called with a dictionary providing current context information when an extension is triggered:\n\n```swift\n/// Starts the extension.\nfunc perform(with extraInfo: [AnyHashable: Any])\n\n/// Completes the extension.\nfunc finish()\n```\n\nThe `extraInfo` will provide different information for different `DKImageExtensionType`:\n\n##### Camera\n\n```swift\nlet didFinishCapturingImage = extraInfo[\"didFinishCapturingImage\"] as? ((UIImage, [AnyHashable : Any]?) -\u003e Void)\nlet didCancel = extraInfo[\"didCancel\"] as? (() -\u003e Void)\n```\n\nFor a custom camera example, see [CustomCameraExtension](https://github.com/zhangao0086/DKImagePickerController/tree/develop/Example/DKImagePickerControllerDemo/CustomCamera).\n\n##### InlineCamera\nThe `extraInfo` is the same as for `Camera`.\n\n##### Photo Gallery\n\n```swift\nlet groupId = extraInfo[\"groupId\"] as? String\nlet presentationIndex = extraInfo[\"presentationIndex\"] as? Int\nlet presentingFromImageView = extraInfo[\"presentingFromImageView\"] as? UIImageView\n```\n\n##### Photo Editor\n\n```swift\nlet image = extraInfo[\"image\"] as? UIImage\nlet didFinishEditing = extraInfo[\"didFinishEditing\"] as? ((UIImage, [AnyHashable : Any]?) -\u003e Void)\nlet metadata = extraInfo[\"metadata\"] as? [AnyHashable : Any]\n```\n\n## How to use in Objective-C\n\n#### If you use [CocoaPods](http://cocoapods.org/)\n\n* Add the following two lines into your `Podfile`:\n\n    ```\n    pod 'DKImagePickerController'\n    use_frameworks!\n    ```\n* Import the library into your Objective-C file: \n\n    ```objective-c\n    #import \u003cDKImagePickerController/DKImagePickerController-Swift.h\u003e\n    ```\n\n#### If you use it directly in your project\n\n\u003e See also:[Swift and Objective-C in the Same Project](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html)\n\n* Drag and drop the [DKCamera][DKCamera], `DKImageManager` and `DKImagePickerController` to your project\n* Import the library into your Objective-C file: \n\n    ```objective-c\n    #import \"YourProductModuleName-Swift.h\"\n    ```\n\n---\nthen you can:\n\n```objective-c\nDKImagePickerController *pickerController = [DKImagePickerController new];\n\n [pickerController setDidSelectAssets:^(NSArray * __nonnull assets) {\n     NSLog(@\"didSelectAssets\");\n }];\n \n [self presentViewController:pickerController animated:YES completion:nil];\n```\n\n## Localization\nThe default supported languages:\n\n\u003e en, es, da, de, fr, hu, ja, ko, nb-NO, pt_BR, ru, tr, ur, vi, ar, it, zh-Hans, zh-Hant\n\nYou can also add a hook to return your own localized string:\n\n```swift\nDKImagePickerControllerResource.customLocalizationBlock = { title in\n    if title == \"picker.select.title\" {\n        return \"Test(%@)\"\n    } else {\n        return nil\n    }\n}\n```\n\nor images:\n\n```swift\nDKImagePickerControllerResource.customImageBlock = { imageName in\n    if imageName == \"camera\" {\n        return DKImagePickerControllerResource.photoGalleryCheckedImage()\n    } else {\n        return nil\n    }\n}\n```\n\n## Contributing to this project\nIf you have feature requests or bug reports, feel free to help out by sending pull requests or by creating new issues.\n\n## License\nDKImagePickerController is released under the MIT license. See LICENSE for details.\n\n[mitLink]:http://opensource.org/licenses/MIT\n[docsLink]:http://cocoadocs.org/docsets/DKImagePickerController\n[DKCamera]:https://github.com/zhangao0086/DKCamera\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhangao0086%2FDKImagePickerController","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhangao0086%2FDKImagePickerController","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhangao0086%2FDKImagePickerController/lists"}