Git Product home page Git Product logo

paparazzo's Introduction

Overview

Version License Build Status

Paparazzo is a component for picking and editing photos.

Key Features
📷 Taking photos using camera
📱 Picking photos from user's photo library
✂️ Photo cropping and rotation
💧 Applying filters to photos

Demo

Contents

There are two options to install Paparazzo using CocoaPods.

Using Marshroute:

pod "Paparazzo"

or if you don't use Marshroute and prefer not to get it as an additional dependency:

pod "Paparazzo/Core"

You can use either the entire module or photo library exclusively.

Initialize module assembly using Paparazzo.AssemblyFactory (or Paparazzo.MarshrouteAssemblyFactory if you use Marshroute):

let factory = Paparazzo.AssemblyFactory()
let assembly = factory.mediaPickerAssembly()

Create view controller using assembly's module method:

let data = MediaPickerData(
    items: items,
    autocorrectionFilters: filters,
    selectedItem: items.last,
    maxItemsCount: maxItemsCount,
    cropEnabled: true,
    autocorrectEnabled: true,
    cropCanvasSize: cropCanvasSize
)

let viewController = assembly.module(
    data: data,
    routerSeed: routerSeed,    // omit this parameter if you're using Paparazzo.AssemblyFactory
    configure: configure
)

Method parameters:

  • items — array of photos that should be initially selected when module is presenter.
  • filters — array of filters that can be applied to photos.
  • selectedItem — selected photo. If set to nil or if items doesn't contain any photo with matching identifier, then the first photo in array will be selected.
  • maxItemsCount — maximum number of photos that user is allowed to pick.
  • cropEnabled — boolean flag indicating whether user can perform photo cropping.
  • autocorrectEnabled — boolean flag indicating whether user can apply filters to photo .
  • cropCanvasSize — maximum size of canvas when cropping photos. (see Memory constraints when cropping).
  • routerSeed — routerSeed provided by Marshroute.
  • configure — closure that allows you to provide module's additional parameters.

Additional parameters is described in protocol MediaPickerModule:

  • setContinueButtonTitle(_:), setContinueButtonEnabled(_:) , setContinueButtonVisible(_:) and setContinueButtonStyle(_:) allow to customize "Continue" button text and availability.
  • setAccessDeniedTitle(_:), setAccessDeniedMessage(_:) and setAccessDeniedButtonTitle(_:) allow to customize "Access Deined" view texts.
  • setCropMode(_:) allow to customize photo crop behavior.
  • onItemsAdd is called when user picks items from photo library or takes a new photo using camera.
  • onItemUpdate is called after user performed cropping.
  • onItemAutocorrect is called after applying filter.
  • onItemMove is called after moving photo.
  • onItemRemove is called when user deletes photo.
  • onFinish and onCancel is called when user taps Continue and Close respectively.

When cropping photo on devices with low RAM capacity your application can crash due to memory warning. It happens because in order to perform actual cropping we need to put a bitmap of the original photo in memory. To descrease a chance of crashing on older devices (such as iPhone 4 or 4s) we can scale the source photo beforehand so that it takes up less space in memory. cropCanvasSize is used for that. It specifies the size of the photo we should be targeting when scaling.

Initialize module assembly using Paparazzo.AssemblyFactory (or Paparazzo.MarshrouteAssemblyFactory if you use Marshroute):

let factory = Paparazzo.AssemblyFactory()
let assembly = factory.photoLibraryAssembly()

Create view controller using assembly's module method:

let viewController = assembly.module(
    selectedItems: selectedItems,
    maxSelectedItemsCount: maxSelectedItemsCount,
    routerSeed: routerSeed,    // omit this parameter if you're using Paparazzo.AssemblyFactory
    configure: configure
)
  • selectedItems — preselected photos (or nil).
  • maxItemsCount — maximum number of photos that user is allowed to pick.
  • routerSeed — routerSeed provided by Marshroute.
  • configure — closure used to provide additional module setup.

MaskCropper is a module which provides easy way to customize cropping experience. See CroppingOverlayProvider protocol to get more details.

Initialize module assembly using Paparazzo.AssemblyFactory (or Paparazzo.MarshrouteAssemblyFactory if you use Marshroute):

let factory = Paparazzo.AssemblyFactory()
let assembly = factory.maskCropperAssembly()

Create view controller using assembly's module method:

let data = MaskCropperData(
    imageSource: photo.image,
    cropCanvasSize: cropCanvasSize
)
let viewController = assembly.module(
    data: data,
    croppingOverlayProvider: croppingOverlayProvider,
    routerSeed: routerSeed,    // omit this parameter if you're using Paparazzo.AssemblyFactory
    configure: configure
)
  • imageSource — photo that should be cropped.
  • croppingOverlayProvider — provider from CroppingOverlayProvidersFactory.
  • routerSeed — routerSeed provided by Marshroute.
  • configure — closure used to provide additional module setup.

Scanner is a module which provides easy way to handle realtime stream from camera. See ScannerOutputHandler protocol to get more details.

Demo

Initialize module assembly using Paparazzo.AssemblyFactory (or Paparazzo.MarshrouteAssemblyFactory if you use Marshroute):

let factory = Paparazzo.AssemblyFactory()
let assembly = factory.scannerAssembly()

Create view controller using assembly's module method:

let data = ScannerData(
    initialActiveCameraType: .back,
    cameraCaptureOutputHandlers: []
)
let viewController = assembly.module(
    data: data,
    routerSeed: routerSeed,    // omit this parameter if you're using Paparazzo.AssemblyFactory
    configure: configure
)
  • initialActiveCameraType — preferred camera when starting the module (front or back).
  • cameraCaptureOutputHandlers — array of handlers that confirm the ScannerOutputHandler protocol.
  • routerSeed — routerSeed provided by Marshroute.
  • configure — closure used to provide additional module setup.

You can customize colors, fonts and icons used in photo picker. Just pass an instance of PaparazzoUITheme to the initializer of assembly factory.

var theme = PaparazzoUITheme()
theme.shutterButtonColor = .blue
theme.accessDeniedTitleFont = .boldSystemFont(ofSize: 17)
theme.accessDeniedMessageFont = .systemFont(ofSize: 17)
theme.accessDeniedButtonFont = .systemFont(ofSize: 17)
theme.cameraContinueButtonTitleFont = .systemFont(ofSize: 17)
theme.cancelRotationTitleFont = .boldSystemFont(ofSize: 14)

let assemblyFactory = Paparazzo.AssemblyFactory(theme: theme)

Photos picked by user via Paparazzo is provided to you either as MediaPickerItem (when using MediaPicker module) or as PhotoLibraryItem (when using PhotoLibrary module). Both of these enitities are just wrappers around ImageSource, which is a protocol that allows you to get different image representations regardless of where it comes from. To find out how to use it go to https://github.com/avito-tech/ImageSource

You can see the list of supported languages here. If you don't see your language, we encourage you to contribute to the project by creating pull request that adds Localizable.strings file for that language.

If you're not satisfied with a string that is provided by Paparazzo, you can override it in your project. Just add Paparazzo.strings to your main bundle. Override only the strings you need (you can see an example of this in PaparazzoExample project).

License

MIT

paparazzo's People

Stargazers

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

Watchers

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

paparazzo's Issues

Fatal error: Not enough bits to represent the passed value

When i am cropping a photo and tap to the check/OK button then i get this error
Fatal error: Not enough bits to represent the passed value

public init<T: Hashable>(hashable: T) {
    self.init(int32Value: Int32(hashable.hashValue))
}

ImageRequestId.swift

Generic T could not be inferred

@prn @eshkinkot @dkostyrev @pkorobeinikov @lahmatiy Im trying to get an image using your fullresolutionimage function, but I keep getting an error called Generic Paramerter T could not be inferred. Here is my code. All I want to do is get a uiimage from an array. I don't want to set the image I just want to get it for the i or path of an array. But im having Alot of issues. I love this library but I can't use it if I can't access the images properly. Because getting the image data and converting it to a uiimage and then converting it to a jpeg to save it nicely to my server is taking forever. Im talking 5 min to save 5 images. And that why I need a function to just get the uiimage directly.

var photos2: [ImageSource]?
self.photos2?.forEach{ path in
myGroup.enter()
path.fullResolutionImage({ (image) in
})
}

iPhone x support

@HiveHicks Great repository, but when do you think this project will fully be supported for the iPhone x thanks.

Swift 4 support

Thanks for the awesome framework please can you update it to Swift 4 to support new apps built in swift 4.
Keep Up the good work  

Accessing all the images in ImageSource

@HiveHicks Hello, as I've said before this is a great project. Its the only easily editable photo/camera editing app which I like. But when a user clicks on the media picker to present the paparazzo camera and takes or selects all the photos he or she wants and then clicks the button. on that done button I am passing all 25 images in a segue to another view controller where it will then be accessed in a custom image slider. But I keep getting this error. "Could not cast value of type 'ImageSource.PHAssetImageSource' (0x10e9f17c8) to 'UIImage' (0x110e290b0)." could you please help me. Here is my code.

Paparazzo view controller:
screen shot 2017-03-29 at 8 59 28 pm

`@IBAction private func showPhotoLibrary() {
var theme = PaparazzoUITheme()
theme.shutterButtonColor = UIColor.blue.cgColor
theme.shutterButtonDisabledColor = UIColor.black.cgColor
theme.accessDeniedTitleFont = .boldSystemFont(ofSize: 17)
theme.accessDeniedMessageFont = .systemFont(ofSize: 17)
theme.accessDeniedButtonFont = .systemFont(ofSize: 17)
theme.cameraContinueButtonTitleFont = .systemFont(ofSize: 17)
theme.cancelRotationTitleFont = .boldSystemFont(ofSize: 14)
let assemblyFactory = Paparazzo.AssemblyFactory(theme: theme)
let assembly = assemblyFactory.photoLibraryAssembly()

    let galleryController = assembly.module(
        selectedItems: [],
        maxSelectedItemsCount: 5,
        configuration: { [weak self] module in
            weak var module = module
            module?.onFinish = { result in
                
                if case let .selectedItems(photoLibraryItems) = result {
                    self?.photos = photoLibraryItems.map { $0.image }
                    self?.updateUI()
                    self?.performSegue(withIdentifier: "ShowNow", sender: self?.photos)
                }
            }
        }
    )
    
    let navigationController = UINavigationController(rootViewController: galleryController)
    
    present(navigationController, animated: true, completion: nil)
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if (segue.identifier == "ShowNow") {
        let pivc: view2ViewController? = segue.destination as? view2ViewController
        
        pivc?.arrImages = photos
        // here images is the array of images
        
    }
}`

Photo slider view controller:
screen shot 2017-03-29 at 8 59 20 pm

`@IBOutlet weak var imgSlider: UIView!
var passedPhotos: [ImageSource]?
var arrImages = Array()
fileprivate var sliderVc1: LIHSliderViewController!

override func viewDidLoad() {
super.viewDidLoad()
let slider1: LIHSlider = LIHSlider(images: arrImages as! [UIImage]) I'm getting this error "Could not cast value of type 'ImageSource.PHAssetImageSource' (0x10e9f17c8) to 'UIImage' (0x110e290b0)." right here. Its a thread break error. So if you can show me how I can access all the images from the paparazzo view controller, I'd really appreciate it. Thanks
`

Can not install Paparazzo with SDWebImage

Can not install Paparazzo with SDWebImage

I used pod list from PaparazzoExample_NoMarshroute sample
screen shot 2017-05-02 at 11 08 38

Console log

| => pod install
Analyzing dependencies
[!] Unable to satisfy the following requirements:

- `Paparazzo/SDWebImage` required by `Podfile`

None of your spec sources contain a spec satisfying the dependency: `Paparazzo/SDWebImage`.

Pod file

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'PhotoTest' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for PhotoTest

  pod 'Paparazzo/Core'
  pod 'Paparazzo/SDWebImage'
  pod 'ImageSource/Core'
  pod 'ImageSource/PHAsset'
  pod 'ImageSource/Local'
  pod 'ImageSource/Remote'
  pod 'ImageSource/SDWebImage'

  
  target 'PhotoTestTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'PhotoTestUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

Main.Storyboard

@prn @limarc @eshkinkot @dkostyrev @lahmatiy First of all, this project is the best camera project I've personally seen on github by far. But theres one thing thats got me confused and frustrated. So I have a construction app that takes pictures of construction sites. At the end of filling out the information, a user will click on the button to present the camera view Is there anyway you guys could make an example implementing this project with a uistoryboard.

pod install

@HiveHicks I'm trying to install the pods for the updated project but all im getting is the files from the old version. I did pod 'Paparazzo' and my minimum deployment target is iOS 9. What do you think could be the problem

Random camera freezes & lags

Good day!

When I using the paparazzo controller found such a problem.
When opening of the paparazzo camera, camera has terrible lags and freezes.

I can not find the pattern and thought, maybe I did something wrong, and there is a memory leak and loss of resources phone.

But, I discovered a strange pattern
This bug only occurs when maxItemsCount = 1 (But sometimes everything is okay)

I checked example from the repository. I also got this bug

Recorded a little video for more understanding:
https://www.youtube.com/watch?v=O7IhHAdLxDw

3d touch support

Please, support 3d touch in your awesome library!
Marshroute 0.4.2 will perfectly suite your needs to support this astonishing feature!
Feel free to ask me about implementation details :)

Add trim box

i saw the PhotoTweak, but the i add the rotate 90 fail, and i enjoy the style of Paparazzo
so, is there any plan to add the trim box.
why Apple do not open the permission of Photo.app editing model 😂

Camera View is not appearing !

I am using code snippets from storyboard example.
Everything works fine except for camera view that is showing nothing(but a white background).
The strange thing , that i take can take pictures.
PS : Swift 4 , iOS 11 and i converted Paparazzo pod to swift 4
Any help ?

Failed to bind EAGLDrawable

Hi, after a continuous use of the camera in mediapicker, at some point all the buttons are like stuck or disabled but the camera view keeps displaying normally. I get the following error in the log :

Failed to bind EAGLDrawable: <CAEAGLLayer: 0x282b9fc60> to GL_RENDERBUFFER 2
Failed to make complete framebuffer object 8cd6

Please, help me with this issue.

Thanks in advance.

App freeze when accessing the Photo library when app is 1st installed on iOS 15.2

Context:
Using Xcode 13.2 and building on iOS 15.2 devices
When installing the app for the 1st time on a device or simulator.

https://developer.apple.com/forums/thread/696804

Solution
Before iOS 15.2 version we could register PHPhotoLibrary.shared().register(self) without authorization, in iOS 15.2 it is not possible, you will get an error. You have to request authorization(requestAuthorization(_:)) for register PHPhotoLibrary.shared().register(self).

How to implement it?

Pod conflict with my project

My project already contains references to Moya, Moya depends on alamofire, and others also depends on SDWebimage. Now how can I solve it?😣
截屏2021-08-20 下午5 26 43

square image camera

@HiveHicks Hey, so I want to use this camera to take and crop to square images. My question, does this camera already convert full screen images to square images, or do I have to do something or is there already a call i can make in the papparazo camera to make it a square camera. Thanks I really need a response for the next launch.

Crop isn't working

This pod is awesome but the crop doesn't seem to be working for me. When I click on the crop icon nothing happens on screen and I get this log:

2018-06-17 02:46:43.291844+0100 AppName[2095:993923] [ImageManager] Unable to load image data, /var/mobile/Media/DCIM/100APPLE/IMG_0841.JPG

Does anyone know why this is coming up?

MVC version?

Hi, any plans for MVC version? The VIPER is great but to I can't understand the implementation :)

Support for gallery albums

At the moment I can select a photos only from the full camera roll. It would be nice to be able to select photos from the beforehand created alboms (like Favorites)

Problem with building project

I added paparazzo to the podfile, then did 'pod install', tried to build the project and received error:

2018-03-28 13 44 53

FYI

Maybe I will make a PR to fix the issue if I have time.

How can selected photos be uploaded on server?

I am trying to upload photos on server using Alamofire like this without success:

Alamofire.upload(multipartFormData: { multipartFormData in
       for photo in self.photos{
        photo.fullResolutionImageData() { data in
            multipartFormData.append(data!, withName: "uploaded_file", fileName: "\(Date().timeIntervalSince1970).jpeg", mimeType: "image/jpeg")
           }
       }

getting error 200: esponseSerializationFailureReason.inputDataNilOrZeroLength

Carthage installation

I want to use carthage to use this library, please provide a way to use it.

Thanks

Crash on trying show paparazzoViewController

Hi, I just created empty project and add Paparazzo pod from 'develop' branch.

Then I trying start project and it crashes.

Here code of my ViewController

import UIKit
import Paparazzo

class ViewController: UIViewController {

	override func viewDidLoad() {
		super.viewDidLoad()
		showPicker()
	}

	private func showPicker() {
		let viewController = PaparazzoFacade.paparazzoViewController(
					theme: PaparazzoUITheme(),
					parameters: MediaPickerData(
						items: [],
						maxItemsCount: 3
					),
					onFinish: { images in
						debugPrint(images)
					}
				)

				self.present(viewController, animated: true, completion: nil)
	}
}

Here my Podfile

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
inhibit_all_warnings!

target 'testPaparazzo' do
  use_frameworks!

  pod 'Paparazzo/Core', :git => 'https://github.com/avito-tech/Paparazzo.git', :branch => 'develop'
end

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.