• Stars
    star
    769
  • Rank 59,078 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 7 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Custom iOS camera and photo picker with editing capabilities

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

Installation

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"

Usage

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

Presenting entire module

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 of MediaPicker module

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.

Memory constraints when cropping

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.

Presenting photo library

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.

Presenting mask cropper

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.

Presenting scanner

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.

UI Customization

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)

ImageSource

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

Localization

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

More Repositories

1

playbook

AvitoTech team playbook
1,443
star
2

avito-android

Infrastructure of Avito android
Kotlin
356
star
3

Emcee

Emcee is a tool that runs Android and iOS tests in parallel using multiple simulators and emulators across many servers
Swift
331
star
4

bioyino

High performance and high-precision multithreaded StatsD server
Rust
229
star
5

netramesh

Ultra light service mesh for any orchestrator
Go
228
star
6

go-transaction-manager

Transaction manager for GoLang
Go
227
star
7

Marshroute

Marshroute is an iOS Library for making your Routers simple but extremely powerful
Swift
224
star
8

deepsecrets

Secrets scanner that understands code
Python
180
star
9

aqueduct

Framework for create performance-efficient prediction
Python
171
star
10

Mixbox

iOS UI testing framework https://t.me/mixbox_english https://t.me/mixbox_russian
Swift
152
star
11

go-mutesting

Mutation testing for Go source code. Fork from https://github.com/zimmski/go-mutesting
Go
145
star
12

krop

Small widget for image cropping in Instagram-like style
Kotlin
126
star
13

avitotech-presentations

Go
112
star
14

autumn-2021-intern-assignment

98
star
15

internship_backend_2022

Тестовое задание на позицию стажера-бэкендера
Go
84
star
16

Calcifer

Calcifer
Swift
72
star
17

nginx-log-collector

nginx-log-collector
Go
55
star
18

sx-frontend-trainee-assignment

Тестовое задание для стажёра Frontend в команду Seller Experience
53
star
19

Konveyor

Kotlin
48
star
20

auto-backend-trainee-assignment

Тестовое задание на позицию бекенд разработчика в юнит Авто
42
star
21

navigator

Multicluster service mesh solution based on envoy
Go
39
star
22

pulemet

Controlled RPS for interservice communication
Python
39
star
23

android-ui-testing

Kotlin
39
star
24

python-trainee-assignment

Тестовое задание по python
37
star
25

normalize

Go
35
star
26

adv-backend-trainee-assignment

Тестовое задание для стажёра Backend в команду Advertising
29
star
27

frontend-trainee-assignment-2023

27
star
28

internship_frontend_2022

Тестовое задание на позицию стажера-фронтендера
TypeScript
26
star
29

job-backend-trainee-assignment

Тестовое задание на позицию стажера-бекендера в юнит "Работа"
26
star
30

safedeal-frontend-trainee

22
star
31

pg_reindex

Console utility for rebuilding indexes and primary keys for PostgreSQL in automatic mode with analysis of index bloating and without table locking
Python
21
star
32

msg-backend-trainee-assignment

В ДАННЫЙ МОМЕНТ НЕ АКТУАЛЬНО! Тестовое задание на позицию стажера-бекендера
21
star
33

internship

Тестовое задание для iOS-стажировки
20
star
34

geo-backend-trainee-assignment

20
star
35

android-trainee-task-2021

20
star
36

blur-layout

Support for blurred semitransparent backgrounds in Android.
Assembly
19
star
37

verticals

Публичный репозиторий кластера Verticals
19
star
38

pro-fe-trainee-task

Тестовое задание для FE стажера в Авито Pro (Команда ARPU)
19
star
39

ios-trainee-problem-2021

Тестовое задание для стажера по направлению iOS
19
star
40

smart-redis-replication

Go
18
star
41

mi-backend-trainee-assignment

Тестовое задание для стажёра Backend в команду MI
17
star
42

dba-utils

Shell
17
star
43

clickhouse-vertica-udx

UDF to seamlessly connect ClickHouse to Vertica using external tables
C++
15
star
44

abito

Python package for hypothesis testing. Suitable for using in A/B-testing software
Python
15
star
45

prop-types-definition

Patch for prop-types to get property type definition in runtime
JavaScript
15
star
46

tm-backend-trainee

Тестовое задание для стажёра Backend в команду Trade Marketing
13
star
47

CommandLineToolkit

Small swift package to create command line tools faster
Swift
13
star
48

antibot-developer-trainee

Тестовая задача для разработчика-стажёра в команду Информационной безопасности Авито для защиты сайта от ботов
13
star
49

bx-backend-trainee-assignment

Тестовое задание на позицию стажера-бекендера в юнит Buyer Experience
12
star
50

mx-backend-trainee-assignment

Тестовое задание для стажёра Backend в команду MX
11
star
51

internship_ios_2022

Тестовое задание на позицию стажёра в iOS
Swift
10
star
52

patterns-and-practices-abstracts

9
star
53

dba-docs

PLpgSQL
9
star
54

qa-trainee-task

Тестовое задание для стажёра-автоматизатора
8
star
55

gravure

Image processing microservice
Rust
8
star
56

ImageSource

Image abstraction toolkit
Swift
8
star
57

pgmock

PostgreSQL 9.4+ extension for unit tests
PLpgSQL
8
star
58

mi-trainee-task-2021

7
star
59

puppet-controlrepo-template

Шаблон control repo для Puppet к статье «Инфраструктура как код в Авито: уроки которые мы извлекли»
Ruby
7
star
60

ap-frontend-trainee-assignment

7
star
61

pro-backend-trainee-assignment

6
star
62

mi-trainee-task

Тестовое задание для стажера в Market Intelligence.
6
star
63

android-trainee-task

6
star
64

ShopX-QA-trainee

задания к собеседованию
6
star
65

ios-trainee-problem

Задача для стажера на платформу iOS
6
star
66

iOS-trainee-assignment-2023

5
star
67

protocol-writer

Simplest of apps to write timed protocols from interviews
JavaScript
5
star
68

bx-android-trainee-assigment

5
star
69

safedeal-backend-trainee

5
star
70

puppet-module-template

Шаблон Puppet модуля к статье «Инфраструктура как код в Авито: уроки которые мы извлекли»
Ruby
5
star
71

android-peerlab-moscow

5
star
72

GraphiteClient

Lightweight Swift framework for feeding data into Graphite and statsD.
Swift
4
star
73

video-course-patterns-and-practices

PHP
4
star
74

xrpcd

PostgreSQL RPC built on top of pgq.
Python
4
star
75

doner

Centralized file downloading service
Rust
4
star
76

trainspotting

Python Dependency Injector based on interface binding
Python
4
star
77

moira

Go
3
star
78

qa-trainee-general

Тестовое задание для QA-cтажёра
3
star
79

aaa-ml-sys-design

ML System Design lectures materials
Python
3
star
80

aaa-ml-datasets-course

Репозиторий курса по созданию датасетов Академии Аналитиков Авито
Jupyter Notebook
3
star
81

vas-frontend-trainee-assignment

Задание для стажёра в команду VAS
2
star
82

Emcee.cloud.action

GItHub action for emcee.cloud
Shell
2
star
83

moira-client

Python
2
star
84

alert-autoconf

Python
2
star
85

homebrew-tap

Homebrew Tap of Avito products and tools
Ruby
2
star
86

avito-pixel

HTML
2
star
87

qa-into-CoE-trainee-task

Тестовое задание для стажёра QA в Центр экспертизы по Обеспечению качества
2
star
88

moira-web

JavaScript
1
star
89

test-asap

Package for easy to start browser testing
JavaScript
1
star
90

EmceePluginSupport

Swift package that allows to extend Emcee with plugins
Swift
1
star
91

avito-vault

Puppet модуль, автоматизирующий выкладку секретов из vault.
Ruby
1
star
92

brave-new-billing

Тестовое задание для backend-стажёра в юнит Billing, Avito
1
star
93

Emcee.cloud-CLI

Shell
1
star