Git Product home page Git Product logo

avatar-capture-ios's Introduction

What is AvatarCapture?

Writing a ground-up solution for taking profile pictures in iOS can be a pain and time consuming. AvatarCapture is a Swift based library inspired by ZCSAvatarCapture whose purpose is to make it as easy as possible to start your camera(front facing or rear), allow you to snap a photo or choose a photo from your Photos library.

Installation

Note: AvatarCapture has a minimum deployment target of iOS 10

Edit your PodFile:
pod 'AvatarCapture'

Then run pod install

Features

  • Display an existing UIImage
  • Start the iPhone camera for capture
  • Swap cameras from front facing to rear and vice versa
  • Choose a photo from the iPhone library

Plans

  • allow more flexibility in where buttons are positioned
  • add custom elements/subviews
  • Change/choose shape of avatar profile

Getting Started

Getting started with AvatarCapture is super easy!

First, initialize the view controller(anywhere but viewDidLoad is common):

 let avatarCaptureController = AvatarCaptureController()
 avatarCaptureController.delegate = self
 avatarCaptureController.image = UIImage.init(named: "an_existing_image.png")
 avatarView.addSubview((avatarCaptureController?.view)!)

AvatarCaptureController subscribes to AvatarCaptureControllerDelegate and is required for retrieving the UIImage after selecting a photo

In this example, avatarView is a UIView defined in a storyboard. Whatever the width and height of this UIView is will determine the dimensions of the avatar.

Helper Methods

startCapture() - Begins capturing the output from your iPhone camera and displays the on screen buttons to interact with your camera
endCapture() - Stops the live preview of the iPhone camera. This method does not need to be explicitly called in most situations
swapCameras() - Swaps the live preview from the front to rear camera and vice versa. This method does not need to be explicitly called in most situations.
showImagePicker() - Displays the Photos library for choosing an image

How do I get my image?

Once you've subscribed to the AvatarCaptureControllerDelegate protocol, you can be notified when an image was selected and when the image selection was cancelled:

extension MyViewController: AvatarCaptureControllerDelegate {
    func imageSelected(image: UIImage) {
        print("image Selected")
    }
    
    func imageSelectionCancelled() {
        print("image selection cancelled")
    }
}

AvatarCapture In Action

Don't I look excited...?
Capture

Thanks

Berend Ozceri - @berendo for thinking of doing this
ZCSAvatarCapture for doing this first

Feedback

Please feel free to create issues if bugs are found or if enhancements or new features are desired

avatar-capture-ios's People

Contributors

johnmurphy01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

avatar-capture-ios's Issues

Touch position image

Allow the user to touch/drag the selected image within the viewable area. This is especially crucial when selecting an image from the library.

Ability to add custom buttons

As of now, the buttons on the screen are statically positioned by AvatarCapture. I would like to be able to allow users to add their own buttons and/or position the items where they want.

Choose shape of avatar aperture area

Allow the user to choose the shape of the aperture area(where the photo is presented). Circular seems like the most popular shape but don't want to leave rectangle out, or even heart :)

Camera orientation

My app shows the views in landscape orientation. The preview layer of the camera can be changed? Always appears in portrait mode.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.