FMPhotoPicker is a modern, simple and zero-dependency photo picker with an elegant and customizable image editor

Overview

FMPhotoPicker

MIT licensed Carthage compatible Pod Compatible Build

FMPhotoPicker is a modern, simple and zero-dependency photo picker with an elegant and customizable image editor

Quick demo

Batch select/deselect
Smooth transitions
Filter
Crop
FMPhotoPicker FMPhotoPicker FMPhotoPicker FMPhotoPicker

Features

  • Support both single and multiple selection
  • Support batch selection/deselection by swipe gesture
  • Support preview
  • Support simple image editor with filter and cropping functions
  • Support force crop mode
  • Support rounded image preview
  • Support adding self-define cropping
  • Support adding self-define filter
  • Support video player
  • Support custom confirmation view
  • Support language customization

Requirements

  • iOS 9.0+

Installation

SwiftPM

dependencies: [
  .package(url: "https://github.com/congnd/FMPhotoPicker.git", .exact("1.3.0")),
]

Carthage

Insert the following line in your Carthfile:

git "[email protected]:congnd/FMPhotoPicker.git"

and run carthage update FMPhotoPicker

CocoaPods

FMPhotoPicker is now available in CocoaPods
You want to add pod 'FMPhotoPicker', '~> 1.3.0' similar to the following to your Podfile:

target 'MyApp' do
  pod 'FMPhotoPicker', '~> 1.3.0'
end

Then run a pod install inside your terminal.

Usage

Create a configuration object

var config = FMPhotoPickerConfig()

For details, see Configuration

Picker

let picker = FMPhotoPickerViewController(config: config)
picker.delegate = self
self.present(picker, animated: true)

From iOS 10, you have to add the Privacy - Photo Library Usage Description into your Info.plist file.

Editor

let editor = FMImageEditorViewController(config: config, sourceImage: image)
editor.delegate = self
self.present(editor, animated: true)

Delegation methods

  • Implement FMPhotoPickerViewControllerDelegate protocol to handle selected photos.
func fmPhotoPickerController(_ picker: FMPhotoPickerViewController, didFinishPickingPhotoWith photos: [UIImage])
func fmPhotoPickerController(_ picker: FMPhotoPickerViewController, didFinishPickingPhotoWith assets: [PHAsset])

If you prefer to receive selected photos in type of PHAsset instead of UIImage then don't forget to set the shouldReturnAsset to true and implement the corresponding delegation method.

  • Implement FMImageEditorViewControllerDelegate protocol to handle ouput image
func fmImageEditorViewController(_ editor: FMImageEditorViewController, didFinishEdittingPhotoWith photo: UIImage)

Configuration

The configuration supports the following parameters:

Reference

  • mediaTypes
    An array that indicates the media types to be accessed by the picker controller.
    Type: [FMMediaType]
    Default: [.image, .video]

  • selectMode
    Photo selection mode that can be in single or multiple mode.
    Type: : FMSelectMode
    Default is multiple

  • maxImage
    The maximum number of images can be selected. Type: Int
    Default: 10

  • maxVideo
    The maximum number of videos can be selected.
    Type: Int
    Default is 10

  • availableFilters
    Filter options that are used in editor. Set this parameter to nil to make the filter menu be unavailable in the editor FMPhotoEditor provides some default filters that will be fit to you.
    Type: [FMFilterable]?
    Default: all filters are provided by FMPhotoPicker.

  • availableCrops
    Crop options that is used in editor. Set this parameter to nil to make the cropping menu be unavailable in the editor FMPhotoEditor provides some default crops that will be fit to you.
    Type: [FMCroppable]? Default: all crops provided by FMPhotoPicker.

You are not allowed to use the editor without giving it at least one crop option or one filter option

  • useCropFirst
    An option that indicates whether the crop menu should be selected by default in the FMImageEditorViewController.
    Type: Bool
    Default: false

  • alertController
    An alert controller to show the confirmation view to an user with 2 options: Ok or Cancel.
    Type: FMAlertable
    Default: FMAlert

  • shouldReturnAsset
    Whether you want FMPhotoPicker returns PHAsset instead of UIImage. FMPhotoPicker chooses a proper delegation method to be invoked when user finishes picking based on this configuration Type: Bool Default: false

  • forceCropEnabled
    A bool value that indicates whether force mode is enabled.
    If true is set, only the first crop in the availableCrops is used in the editor.
    And that crop's ration becomes force crop ratio.
    Type: FMAlertable
    Default: false

  • eclipsePreviewEnabled
    A bool value that indicates whether the preview of image should be displayed in rounded image.
    Type: Bool Default: false

  • strings
    A dictionary that allows you to customize language for your app.
    For details, see FMPhotoPickerConfig.swift
    Type: Dictionary

Customization

Custom filter

You can freely create your own filter by implementing the FMFilterable protocol.

public protocol FMFilterable {
    func filter(image: UIImage) -> UIImage
    func filterName() -> String
}

Be careful that the filterName is used to determine whether the two filters are the same.
Make sure that your filter's names are not duplicated, especially with the default filters that you want to use.

Custom cropping

Similar as filter function, FMPhotoPicker provides the capability to use your own cropping by implementing the FMCroppable protocol.

public protocol FMCroppable {
    func crop(image: UIImage, toRect rect: CGRect) -> UIImage
    func name(string: [String: String]) -> String
    func icon() -> UIImage
    func ratio() -> FMCropRatio?
}

The func name(strings: [String: String]) -> String will receive the strings configuration from configuration object. It allows you customize the cropping while keeping all your language setting in only one place.

The name() method is also used as identifier for the cropping.
Thus, make sure you do not have any duplicate of the cropping name.

Custom alert view controller

You can use your own view style for the confirmation view by implementing the FMAlertable protocol.

public protocol FMAlertable {
    func show(in viewController: UIViewController, ok: @escaping () -> Void, cancel: @escaping () -> Void)
}

Contact

Follow and contact me on Twitter. If you find an issue, just open a ticket. Pull requests are warmly welcome as well.

License

FMPhotoPicker is released under the MIT license. See LICENSE for details.

Comments
  • Implementing FMFilterable

    Implementing FMFilterable

    Hi,

    I really appreciate the tremendous work you did. I have couple of extra filters to be added on the slider. However I'm not sure how to add them using FMFilterable. I tried several things but truly speaking couldn't manage smoothly.

    If you can support with an example, I really appreciate for that. Thank you, Baris

    opened by barisnurlu 8
  • Video support

    Video support

    Do you plan to add support for picking video like in system picker? I mean smth like this: func fmPhotoPickerController(_ picker: FMPhotoPickerViewController, didFinishPickingVideoWith videos: [URL]) { }

    enhancement 
    opened by sayler8182 8
  • Carthage build error

    Carthage build error

    Hello, I get the following error when building with carthage update --platform iOS and having git "[email protected]:congnd/FMPhotoPicker.git" in Cartfile:

    Module compiled with Swift 5.2.4 cannot be imported by the Swift 5.3 compiler

    I use Xcode version 12.0.

    opened by unixb0y 4
  • FMCrop.ratioCustom is available even I put only FMCrop.ratioSquare and forceCropEnabled = true

    FMCrop.ratioCustom is available even I put only FMCrop.ratioSquare and forceCropEnabled = true

    FMCrop.ratioCustom is available even I put onlyFMCrop.ratioSquare and/or forceCropEnabled = true When I move to Edit image screen, any of FMCrops are not selected and it gives me the opportunity to crop an image as FMCrop.ratioCustom

    opened by Adakhan 4
  • crash in FMLoadingView

    crash in FMLoadingView

    crash fix replace old init method with this one private init() { if let rootVC = (UIApplication.shared.windows.first?.rootViewController) { self.transparentView = UIView(frame: rootVC.view.frame)

        } else {
            let windowFrame = UIApplication.shared.keyWindow?.frame
            self.transparentView = UIView(frame: windowFrame ?? .zero)
        }
        
        self.transparentView.backgroundColor = UIColor(white: 0, alpha: 0.4)
        
        self.indicator = UIActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: 35, height: 35))
        self.indicator.center = self.transparentView.center
        self.indicator.color = .white
        
        self.transparentView.addSubview(self.indicator)
    }
    
    needs investigation 
    opened by engsulta 4
  • Could not load the

    Could not load the "check_on" image referenced from a nib in the bundle with identifier "someID"

    The xcassets couldn't be loaded in the main app target, and there seems to be ways around it: https://stackoverflow.com/questions/33063233/cant-load-images-from-xcasset-in-cocoapods

    opened by hyouuu 3
  • A suggestion to avoid confusion

    A suggestion to avoid confusion

    Your use of the term ForceCrop was not what I expected. In my use case I am having a user pick a profile pic that will be circular, so I need to force them to edit their selected photo with a circle crop. It took me awhile to understand why turning on forceCrop didn't result in that behavior, but rather forces a single crop option. IMHO ForceCrop should be named CropChoice or CropDefault.

    This is an amazing framework, thank you for open sourcing it.

    opened by neodave 3
  • Pod

    Pod

    'Could not load NIB in bundle: 'NSBundle </var/containers/Bundle/Application/.app/Frameworks/FMPhotoPicker.framework> (loaded)' with name 'FMPhotoPickerViewController''

    opened by wakaryry 3
  • Survey about Open Source Image editors for Master's thesis

    Survey about Open Source Image editors for Master's thesis

    Dear Mr. Nguyen,

    My name is Anupama Nedungadi and I am a Master’s student at the University of Geneva. For my thesis, I am looking at internationalization and localization practices in open source image editors, meaning how and why (or why not) the software has been translated into another language. I have curated a list of image editors, graphic editors and the likes hosted on SourceForge, GitHub and GitLab, and this list includes your software congnd/FMPhotoPicker.

    I am contacting you to ask for your participation in a survey. This is a key element of my Master’s thesis. I am aware of the fact that we don't know each other and that you don't owe me anything, but I am really dependent on your help since my topic is quite niche. I also believe we should shine a spotlight on open source software and its translation in particular, as little research has been done in this area recently.

    The survey will be open until the 16th of June 2021, and it should only take you around 10 minutes as most questions are multiple choice. Your answers will be anonymous.

    https://formulaire.unige.ch/outils/limesurveyfac/traduction-interpretation/index.php/697247?lang=en

    Again, thank you for taking the time to read this email and helping a slightly stressed student out!

    Best regards, Anupama Nedungadi

    opened by nedunga0 2
  • Image rotation functionality when we edit the image.

    Image rotation functionality when we edit the image.

    Hello Team, I need an Image rotation functionality along with the filter and crop functionalities. I found the rotation function created inside the FMCropView.swift but it is empty(Screenshot below).

    So could you please help me to achieve the desired result.

    Screenshot 2021-02-03 at 5 07 48 PM

    Thanks in advance.

    opened by Satish24sp 2
  • CocoaPods installing error

    CocoaPods installing error

    Version of my iOS project is 13.5 and Swift 5.

    I am getting attached error when I try to install dependency with CocoaPods.

    I also tried to install dependency with Carthage and it is working.

    Cocoapods
    opened by emrdgrmnci 2
  • Guys. Now I start support in my personal repo (+dark mode)

    Guys. Now I start support in my personal repo (+dark mode)

    Now I added

    • Dark theme appearance.
    • sorting of pictures is the same as a Native Photos App.

    πŸ‘‰πŸ» https://github.com/HanSJin/FMPhotoPicker

    Lets Clone and modify or import pod

    pod 'FMPhotoPicker', :git => 'https://github.com/HanSJin/FMPhotoPicker.git', :commit => '20f6b5f9a84a11e53a9a68b39a648b2fc167f5f1'
    

    And I will develop below later

    • album selection likes Favorite.
    opened by HanSJin 0
  • Feature/swift UI

    Feature/swift UI

    This adds a simple wrapper for SwiftUI users

    It's documented in the Readme - but essentially, it uses a standard fullscreenModal with a binding to an image or an array of images

    struct ContentView: View {
        @State var image:UIImage?
        @State var showPicker:Bool = false
    
        var body: some View {
            VStack {
                if let image {
                    Image(uiImage:image)
                        .resizable()
                        .frame(width:100,height:100)
                }
    
                Button("Pick a Photo") {
                    showPicker = true
                }
    
            }
            .padding()
    		//Note - use fullScreenCover rather than sheet
    		//to avoid display issues on iPads
            .fullScreenCover(isPresented: $showPicker) {
                FMSwiftUIImagePicker(config: FMPhotoPickerConfig(),
                                     selectedImage: self.$image)
            }
        }
    }
    

    For multiple selection - just change the binding to [UIImage]

    opened by ConfusedVorlon 0
  • How to disable photo Editing mode.

    How to disable photo Editing mode.

    config = FMPhotoPickerConfig() config.selectMode = .multiple config.mediaTypes = [.image] config.maxImage = 20 config.maxVideo = 0

    there is no option for disable edit photo in FMPhotoPickerViewController

    opened by naveedmcs 0
  • SDK crashes while showing warning

    SDK crashes while showing warning

    When a user selects more than max allowed images, the app crashes while fetching rootViewController to present warning at line 28 in FMWarningView.swift. See screenshot for reference: Screenshot 2021-11-03 at 3 33 37 PM

    opened by amsubhanTV 2
  • Implement theme colors to UI Elements

    Implement theme colors to UI Elements

    This update will allow the user to set a themeColor when setting up the FMPhotoPickerConfig properties. It colors the filter button, the crop button and all related assets.

    opened by hnoArcos 0
Releases(1.3.0)
Owner
Cong Nguyen
iOS Developer 🍎
Cong Nguyen
React-native-photo-editor - Photo editor using native modules for iOS and Android

?? Image editor using native modules for iOS and Android. Inherit from 2 available libraries, ZLImageEditor (iOS) and PhotoEditor (Android)

Baron Ha. 244 Jan 5, 2023
DTPhotoViewerController - A fully customizable photo viewer ViewController to display single photo or collection of photos, inspired by Facebook photo viewer.

DTPhotoViewerController Example Demo video: https://youtu.be/aTLx4M4zsKk DTPhotoViewerController is very simple to use, if you want to display only on

Tung Vo 277 Dec 17, 2022
A photo gallery for iOS with a modern feature set. Similar features as the Facebook photo browser.

EBPhotoPages ”A photo gallery can become a pretty complex component of an app very quickly. The EBPhotoPages project demonstrates how a developer coul

Eddy Borja 1.7k Dec 8, 2022
PhotoEditor SDK: A fully customizable photo editor for your app.

About PhotoEditor SDK for iOS Our SDK provides tools for adding photo editing capabilities to your iOS application with a big variety of filters that

IMG.LY 116 Jan 1, 2023
πŸ“· A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component ?? v2.0.0-alpha now open!

Muukii 2.8k Jan 3, 2023
πŸ“· A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component ?? v2.0.0-alpha now open!

Muukii 2.8k Jan 2, 2023
An instagram-like image editor that can apply preset filters passed to it and customized editings to a binded image.

CZImageEditor CZImageEditor is an instagram-like image editor with clean and intuitive UI. It is pure swift and can apply preset filters and customize

null 8 Dec 16, 2022
FlaneurImagePicker is an iOS image picker that allows users to pick images from different sources (ex: user's library, user's camera, Instagram...). It's highly customizable.

FlaneurImagePicker is a highly customizable iOS image picker that allows users to pick images from different sources (ex: device's library, device's c

FlaneurApp 17 Feb 2, 2020
Custom iOS camera and photo picker with editing capabilities

Overview Paparazzo is a component for picking and editing photos. Key Features ?? Taking photos using camera ?? Picking photos from user's photo libra

avito.tech 757 Jan 4, 2023
FacebookImagePicker is Facebook album photo picker written in Swift.

Features β€’ Installation β€’ Usage β€’ Translation β€’ License GBHFacebookImagePicker is Facebook's album photo picker written in Swift, built to provide a s

Florian Gabach 231 Dec 17, 2022
A modern photo viewing experience for iOS.

NYTPhotoViewer NYTPhotoViewer is a slideshow and image viewer that includes double-tap to zoom, captions, support for multiple images, interactive fli

The New York Times 2.8k Jan 5, 2023
WLPhotoPicker - A multifunction photo picker for iOS

WLPhotoPicker Example To run the example project, clone the repo, and run pod in

Weang 20 Nov 25, 2022
DGCropImage - A photo cropping tool which mimics Photo.app written by Swift

DGCropImage A photo cropping tool which mimics Photo.app written by Swift. This

donggyu 11 Jul 14, 2022
Photo-Sharing-App - Photo Sharing App With Swift

Photo Sharing App You can register and log in to this application and share your

Yağız Savran 2 Jun 14, 2022
FLImagePicker - A simple image picker supported multiple selection

FLImagePicker A simple image picker supported multiple selection. Features Multiple selection Gesture supported Dark mode Easy modification Installati

Allen Lee 4 Aug 17, 2022
Image Editor iOS App - CLEAN Architecture + MVP Pattern

Image Editor iOS Application - Built using UIKit, CoreData, CoreImage, and URLSession Frameworks with CLEAN Architecture and MVP UI design pattern.

Omran Khoja 8 Nov 30, 2022
A Shortcuts-like and highly customizable SFSymbol picker written in Swift.

SFTintedIconPicker SFTintedIconPicker is a Shortcuts-like and highly customizable SFSymbol picker written in Swift. Features Native Appearance Search

StephenFang 2 Aug 16, 2022
πŸ“Ή Your next favorite image and video picker

Description We all love image pickers, don't we? You may already know of ImagePicker, the all in one solution for capturing pictures and selecting ima

HyperRedink 1.4k Dec 25, 2022
A very useful and unique iOS library to open image picker in just few lines of code.

ImagePickerEasy A very simple solution to implement UIImagePickerController() in your application. Requirements Swift 4.2 and above Installation Image

wajeehulhassan 6 May 13, 2022