Instagram-like photo browser and a camera feature with a few line of code in Swift.

Overview

NOTE: This project is no longer maintained.

We highly recommend YPImagePicker.

Fusuma

Fusuma is a Swift library that provides an Instagram-like photo browser with a camera feature using only a few lines of code.
You can use Fusuma instead of UIImagePickerController. It also has a feature to take a square-sized photo.

Version Platform CI Status Carthage compatible codebeat

Preview

Images

Features

  • UIImagePickerController alternative
  • Cropping images in camera roll
  • Taking a square-sized photo and a video using AVFoundation
  • Flash: On & Off
  • Camera Mode: Front & Back
  • Video Mode
  • Colors fully customizable

Those features are available just with a few lines of code!

Installation

Manual installation

Download and drop the 'Classes' folder into your Xcode project.

Using CocoaPods

Add pod 'Fusuma' to your Podfile and run pod install. Also add use_frameworks! to the Podfile.

use_frameworks!
pod 'Fusuma'

Swift 3

The latest version does support Swift 4.2. If you're still using Swift 3, you can install Fusuma as follows:

pod 'Fusuma', git: '[email protected]:ytakzk/Fusuma.git', branch: 'swift-3'

Fusuma Usage

Import Fusuma import Fusuma then use the following codes in some function except for viewDidLoad and give FusumaDelegate to the view controller.

let fusuma = FusumaViewController()
fusuma.delegate = self
fusuma.availableModes = [FusumaMode.library, FusumaMode.camera, FusumaMode.video] // Add .video capturing mode to the default .library and .camera modes
fusuma.cropHeightRatio = 0.6 // Height-to-width ratio. The default value is 1, which means a squared-size photo.
fusuma.allowMultipleSelection = true // You can select multiple photos from the camera roll. The default value is false.
self.present(fusuma, animated: true, completion: nil)

Delegate methods

// Return the image which is selected from camera roll or is taken via the camera.
func fusumaImageSelected(_ image: UIImage, source: FusumaMode) {

  print("Image selected")
}

// Return the image but called after is dismissed.
func fusumaDismissedWithImage(image: UIImage, source: FusumaMode) {
        
  print("Called just after FusumaViewController is dismissed.")
}

func fusumaVideoCompleted(withFileURL fileURL: URL) {

  print("Called just after a video has been selected.")
}

// When camera roll is not authorized, this method is called.
func fusumaCameraRollUnauthorized() {

  print("Camera roll unauthorized")
}

// Return selected images when you allow to select multiple photos.
func fusumaMultipleImageSelected(_ images: [UIImage], source: FusumaMode) {

}

// Return an image and the detailed information.
func fusumaImageSelected(_ image: UIImage, source: FusumaMode, metaData: ImageMetadata) {

}

How To Customize

let fusuma = FusumaViewController()
fusuma.delegate = self
// ...
fusumaCameraRollTitle = "CustomizeCameraRollTitle"
fusumaCameraTitle = "CustomizeCameraTitle" // Camera Title
fusumaTintColor: UIColor // tint color
// ...
self.present(fusuma, animated: true, completion: nil)

Properties

Prop Type Description Default
fusumaBaseTintColor UIColor Base tint color. UIColor.hex("#c9c7c8", alpha: 1.0)
fusumaTintColor UIColor Tint color. UIColor.hex("#FCFCFC", alpha: 1.0)
fusumaBackgroundColor UIColor Background color. UIColor.hex("#c9c7c8", alpha: 1.0)
fusumaCheckImage UIImage Image of check button.
fusumaCloseImage UIImage Image of close button.
fusumaCropImage Bool Whether to crop the taken image. true
fusumaSavesImage Bool Whether to save the taken image. false
fusumaCameraRollTitle String Text of camera roll title. "Library"
fusumaCameraTitle String Text of carmera title text. Photo
fusumaVideoTitle String Text of video title. Video
fusumaTitleFont UIFont Font for title text. UIFont(name: "AvenirNext-DemiBold", size: 15)

Fusuma for Xamarin

Cheesebaron developed Chafu for Xamarin.
https://github.com/Cheesebaron/Chafu

Author

ytakzk
https://ytakzk.me

Donation

Your support is welcome through Bitcoin 3Ps8tBgz4qn6zVUr5D1wcYrrzYjMgEugqv

License

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

Comments
  • What about Swift 3 version ?

    What about Swift 3 version ?

    Hey thank you for this work !! But when do you think the swift 3 version will be available for a pod update please ? Seem that many developers have issues with Swift 3 upgrade :/

    opened by sebastienboulogne 18
  • Images not rendering in collection view of FSAlbumView in iPad Air and iPad Air 2.

    Images not rendering in collection view of FSAlbumView in iPad Air and iPad Air 2.

    The images in the collectionView of the FSAlbumView are not being rendered in iPad Air and iPad Air 2. The frames are there. Also if I give the background color to the imageView the the background colors are visible. Even when I select the cell, the corresponding image is shown in the imageCropView. But the images are not being rendered in the collection view.

    blackclosed1 redclosed1 blackopen1 redopen1

    opened by leapfrog-saugat 13
  • Crash after updating to iOS 10 , swift 3

    Crash after updating to iOS 10 , swift 3

    after updating to iOS 10 and swift3 when i opened gallery from fusuma* , application got crashed without any log message the only message i got is this : (lldb) and its pointing to - -> 0x185cbcd74 <+8>: b.lo 0x185cbcd8c ; <+32> how can we fix this ??

    opened by billionbucks 10
  • Videos are Muted

    Videos are Muted

    I'm recording videos but they do not have sounds:

    let vc = FusumaViewController()
    vc.hasVideo = true
    vc.delegate = self
    presentViewController(vc, animated: true, completion: nil)
    
    opened by shakked 8
  • A little appearance problem when changing flash mode

    A little appearance problem when changing flash mode

    iosghy02172016144050

    When I clicked the flash button

    iosghy02172016144059

    Another problem is I think you always set the off image to flash button at the beginning no matter the flash mode is on or off.

    opened by ghysrc 8
  •  Integrating Fusuma in my objective-c

    Integrating Fusuma in my objective-c

    Hi there

    I am integrating Fusuma in my objective-c app

    Now i am able to acess FusumaViewController but not able to acess the FusumaDelegate

    I have seen my projectName-Swift.h file i can see the FusumaViewController's function but can not able to see the delegate function in it

    Can someone please help me to resolve the issue

    Thanks in advance

    bug 
    opened by anitalanet 7
  • Wrong crop height ratio according to available modes.

    Wrong crop height ratio according to available modes.

    It is strange for me:

    fusuma.cropHeightRatio = 1.0
    fusumaCropImage = true
    

    I expect the photo to be square. And if:

    fusuma.availableModes = [FusumaMode.camera, FusumaMode.library]
    

    or

    fusuma.availableModes = [FusumaMode.video, FusumaMode.camera]
    

    Everything is good, the area of the photo and the photo itself are square. But if:

    fusuma.availableModes = [FusumaMode.camera]
    

    Despite cropHeightRatio and fusumaCropImage, photo area and photo itself are rectangular.

    bug 
    opened by melancholy13 6
  • Little Space at the bottom(with screen shots)

    Little Space at the bottom(with screen shots)

    First of all, this is a great framework! Thanks a lot!

    May I ask why there's a little small white space at the bottom that is not filled for the first time when I present the fusuma viewcontroller?

    The picture below: first picture is the first time enter in the viewcontroller, the second one is when I tapped back for the second time.

    fullsizeoutput_a73 fullsizeoutput_a74

    opened by Bomiishere 6
  • #242 - Correcting top layout constraints

    #242 - Correcting top layout constraints

    With the new top layout/margin behaviours, the top "nav bar" would appear below the status bar.

    Corrected the constraints to ensure the nav bar covers behind the status bar area. Tested on iPhone 7, but should also fix the problem as reported on iPhone X.

    opened by rstewart22 5
  • Album starts dragging up when I want to crop image

    Album starts dragging up when I want to crop image

    Thanks for a great project!

    In album view

    After having dragged the album up once to reveal more images and then selected one, pinching to zoom/crop and panning the loaded image with one or two fingers would start the dragging up of the album, but the intended action is rather to pinch to zoom or pan the crop view.

    Adding a class variable solved this issue

    var canPanDuringThisTouch = true
    

    Then add the line to the panned() function

        if sender.state == .Began {
    
            let view    = sender.view
            let loc     = sender.locationInView(view)
            let subview = view?.hitTest(loc, withEvent: nil)
    
            if subview == imageCropView && imageCropViewConstraintTop.constant == imageCropViewOriginalConstraintTop {
                // if the pan starts in the image field, don't let this touch start dragging the album, since it's a crop gesture
                canPanDuringThisTouch = false
                return
            }
    

    and in the last } else { , add:

            canPanDuringThisTouch = true // reset this value for the next interaction
    
    opened by thyselius 5
  • Scheme Fusuma is not currently configured for the build action

    Scheme Fusuma is not currently configured for the build action

    Hi, I've just tried to install Fusuma and I get the following error:

    A shell task (/usr/bin/xcrun xcodebuild -workspace /Carthage/Checkouts/Fusuma/Fusuma.xcworkspace -scheme Fusuma -configuration Release CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES -showBuildSettings) failed with exit code 66: xcodebuild: error: Scheme Fusuma is not currently configured for the build action.

    Researching on Carthage issues (https://github.com/Carthage/Carthage/issues/896), I've found that it's an issue with the library. I also tried to install version 0.4.0 and it works, so it's probably an issue with the latest version (0.5.1).

    What should I do?

    opened by rodrigoruiz 5
  • Unable to get path from phAsset

    Unable to get path from phAsset

    I want to get the path of selected images. But, using phAsset from metadata returns nil. I tried the following: None of the ways in the following function worked. ` func getImagesFromAsset(asset: PHAsset) -> URL? { var finalURL: URL?

        let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions()
        options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in
            return true
        }
    

    // PHImageManager.default().requestImage(for: asset, targetSize: CGSize(width: 600, height: 600), contentMode: .aspectFill, options: nil, resultHandler: { (image, info) in // //resultHandler have info ([AnyHashable: Any]) // print(info!["PHImageFileURLKey"]) // finalURL = info!["PHImageFileURLKey"] as! URL // // })

        let imageRequestOptions = PHImageRequestOptions()
        PHImageManager.default().requestImageData(for: asset, options: imageRequestOptions, resultHandler: { imageData, dataUTI, orientation, info in
          if let info = info {
            print("info = \(info)")
          }
          if info?["PHImageFileURLKey"] != nil {
    
            let path = info?["PHImageFileURLKey"] as? URL
             print(path) //here you get complete URL
    
    
            // if you want to save image in document see this.
           // self.saveimageindocument(imageData, withimagename: "DEMO")
          }
        })
        
        asset.requestContentEditingInput(with: options) { (editingInput, info) in
            if asset.mediaType == .image {
                if let strURL = editingInput?.fullSizeImageURL?.absoluteString {
                    print("IMAGE URL: ", strURL)
                } else {
                    print("nill")
                }
            }
        }
        asset.requestContentEditingInput(with: options) { (eidtingInput, info) in
            
            if #available(iOS 11.0, *) {
                let imgUrl = info[UIImagePickerController.InfoKey.imageURL] as? URL
            } else {
                // Fallback on earlier versions
            }
            print("Here")
    

    // print(imgUrl) print(info) print(eidtingInput)

          if let input = eidtingInput, let imgURL = input.fullSizeImageURL {
             // imgURL
            print(imgURL)
            finalURL = imgURL
          }
        }
        return finalURL
    }`
    
    opened by singh-karan-7 0
  • Library no work

    Library no work

    Fusuma not work multiply selected image in gallery, button done not get images. Error is in method

    private func requestImage(with asset: PHAsset, cropRect: CGRect, completion: @escaping (PHAsset, UIImage) -> Void) { DispatchQueue.global(qos: .default).async(execute: { let options = PHImageRequestOptions() options.deliveryMode = .highQualityFormat options.isNetworkAccessAllowed = true options.normalizedCropRect = cropRect options.resizeMode = .exact

            let targetWidth  = floor(CGFloat(asset.pixelWidth) * cropRect.width)
            let targetHeight = floor(CGFloat(asset.pixelHeight) * cropRect.height)
            let dimensionW   = max(min(targetHeight, targetWidth), 1024 * UIScreen.main.scale)
            let dimensionH   = dimensionW * self.getCropHeightRatio()
    
            let targetSize   = CGSize(width: dimensionW, height: dimensionH)
    
            PHImageManager.default().requestImage(for: asset, targetSize: targetSize, contentMode: .aspectFill, options: options) { result, info in
                guard let result = result else { return }
    
                DispatchQueue.main.async(execute: {
                    completion(asset, result)
                })
            }
        })
    }
    
    opened by cioletti 3
  • zoom in or zoom out  image in crop view increase collection view height

    zoom in or zoom out image in crop view increase collection view height

    when I am trying to zoom in or zoom out the image which is in crop view it scrolls up the collection view... this event increase the height of collection view..I want exact same as it works in Instagram..can you please help me to solve this issue

    opened by ritz122 0
  • Reload after auth given

    Reload after auth given

    On iOS 13, after permission is given for camera and library fusma is still blank. The user has to click out and back in before the images show.

    Any way to solve this?

    opened by paulsUsername 4
  • Memory leak issue

    Memory leak issue

    While selecting more than 15 images, it will crash the app due to memory issue. Even in your example demo you can check the same with uploading 15 or more photos.

    Screenshot 2019-07-12 at 1 50 09 PM

    opened by dhara6894 0
Releases(1.1.1)
Owner
Yuta Akizuki
Yuta Akizuki
A camera view controller with custom image picker and image cropping.

ALCameraViewController A camera view controller with custom image picker and image cropping. Features Front facing and rear facing camera Simple and c

Alex Littlejohn 2k Dec 29, 2022
Library for iOS Camera API. Massively increase performance and ease of use within your next iOS Project.

CameraKit helps you add reliable camera to your app quickly. Our open source camera platform provides consistent capture results, service that scales,

CameraKit 628 Dec 27, 2022
Easily take a photo or video or choose from library

FDTake Easily take a photo or video or choose from library ?? Author's tip jar: https://amazon.com/hz/wishlist/ls/EE78A23EEGQB Usage To run the exampl

William Entriken 322 Nov 30, 2022
A better way to operate QR Code in Swift, support iOS, macOS, watchOS and tvOS.

EFQRCode is a lightweight, pure-Swift library for generating stylized QRCode images with watermark or icon, and for recognizing QRCode from images, in

EFPrefix 4.3k Jan 2, 2023
You will learn how to scan QR code with iOS framework.

QR Code Scanner You will learn how to scan QR code with in iOS without using any library. It is as simple to scan QR code in iOS. In this example, We

Nitin Aggarwal 11 Dec 8, 2022
Swift library to easily check the current device and some more info about it.

Usage To run the example project, clone the repo, and run pod install from the Example directory first. let device = Deviice.current device is a Devi

Andrea Mario Lufino 56 Nov 3, 2022
Light weight tool for detecting the current device and screen size written in swift.

Device detect the current  device model and screen size. Installation CocoaPods Device is available through CocoaPods. To install it, simply add the

Lucas Ortis 1.5k Dec 28, 2022
🛰 CoreLocation Made Easy - Efficient & Easy Location Tracker, IP Location, Gecoder, Geofence, Autocomplete, Beacon Ranging, Broadcaster and Visits Monitoring

Location Manager Made Easy SwiftLocation is a lightweight Swift Library that provides an easy way to work with location-related functionalities. No mo

Daniele Margutti 3.2k Dec 30, 2022
:mag_right: A simple and beautiful barcode scanner.

Description BarcodeScanner is a simple and beautiful wrapper around the camera with barcode capturing functionality and a great user experience. Barco

HyperRedink 1.6k Jan 3, 2023
Simply the fastest way to transmit data between iOS/tvOS and OSX

DarkLightning DarkLightning is a lightweight Swift library to allow data transmission between iOS/tvOS devices (Lightning port, Dock connector, USB-C)

Jens Meder 318 Nov 29, 2022
Luminous provides you a lot of information about the system and a lot of handy methods to quickly get useful data on the iOS platform.

Luminous Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 8+ Swift 5 Xcode 1

Andrea Mario Lufino 324 Nov 27, 2022
WatchCon is a tool which enables creating easy connectivity between iOS and WatchOS.

WatchCon WatchCon is a tool which enables creating easy connectivity between iOS and WatchOS Requirements iOS 9.0+ / watchOS 2.0+ CocoaPods CocoaPods

Abdullah Selek 33 Sep 22, 2022
NFC Forum Well Known Type Data Parser for iOS11 and Core NFC

NFCNDEFParse NFC Forum Well Known Type Data Parser for iOS11 and Core NFC. Supports parsing of types: Text - NFCForum-TS-RTD_Text_1.0 2006-07-24 Uri -

Jari Kalinainen 14 Oct 21, 2022
Lightweight Cocoa library for detecting the running device's model and screen size.

Lightweight Cocoa library for detecting the running device's model and screen size. With the newer  devices, developers have more work to do. This li

Sebastian Dobrincu 1.3k Nov 24, 2022
Writes twitter and contact (links) to writable nfcs on iPhone 7+ iOS 14+

nfc writer ios app nfc writer app is a hacky fun side project that writes twitter and contact (links) to writable nfcs. runs on iPhone 7+ iOS 14+. joi

Vivian Phung 5 Nov 23, 2022
⬆️ Rad Media Capture in Swift

NextLevel is a Swift camera system designed for easy integration, customized media capture, and image streaming in iOS. Integration can optionally lev

NextLevel 2k Dec 30, 2022
Simple QRCode reader in Swift

QRCodeReader.swift is a simple code reader (initially only QRCode) for iOS in Swift. It is based on the AVFoundation framework from Apple in order to

Yannick Loriot 1.3k Jan 5, 2023
A simple Swift framework for building reliable Bluetooth LE apps.

Bluejay is a simple Swift framework for building reliable Bluetooth LE apps. Bluejay's primary goals are: Simplify talking to a single Bluetooth LE pe

Steamclock Software 1k Dec 13, 2022
Demo using Terminal.Gui with Llama Swift

Hola! This repo is a demo which shows the use of Llama Swift with Terminal.Gui. Llama is my exploratory project to compile "other languages" for .NET

Eric Sink 6 May 22, 2021