Code Monkey home page Code Monkey logo

photo-editor's Introduction

iOS Photo Editor

Features

  • Cropping
  • Adding images -Stickers-
  • Adding Text with colors
  • Drawing with colors
  • Scaling and rotating objects
  • Deleting objects
  • Saving to photos and Sharing
  • Cool animations
  • Uses iOS Taptic Engine feedback

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate iOS Photo Editor into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'iOSPhotoEditor'
end

Then, run the following command:

$ pod install

Usage

Photo

The PhotoEditorViewController.

let photoEditor = PhotoEditorViewController(nibName:"PhotoEditorViewController",bundle: Bundle(for: PhotoEditorViewController.self))

//PhotoEditorDelegate
photoEditor.photoEditorDelegate = self

//The image to be edited 
photoEditor.image = image

//Stickers that the user will choose from to add on the image         
photoEditor.stickers.append(UIImage(named: "sticker" )!)

//Optional: To hide controls - array of enum control
photoEditor.hiddenControls = [.crop, .draw, .share]

//Optional: Colors for drawing and Text, If not set default values will be used
photoEditor.colors = [.red,.blue,.green]

//Present the View Controller
present(photoEditor, animated: true, completion: nil)

The PhotoEditorDelegate methods.

func doneEditing(image: UIImage) {
    // the edited image
}
    
func canceledEditing() {
    print("Canceled")
}

Live Demo appetize.io

Demo

Demo Video

Demo

Credits

Written by Mohamed Hamed.

Initially sponsored by Eventtus

License

Released under the MIT License.

photo-editor's People

Contributors

dozoisch avatar itsmemihir avatar mhmdrmdn94 avatar mysport12 avatar nazywamsiepawel avatar tsznokwong avatar ttorbik avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

photo-editor's Issues

Mosaic

Can add Mosaic function. thanks

Top tool bar - Done Button overlaps when moving element during text edit

Hello,

I just noticed that if you move an element (e.g sticker) while editing a text, when the you finish the move gesture both toolbar (top) and done button are displayed on screen.

Not sure if best way to stop it is to detect that there is a textView that is firstResponder in #moveView (state == ended) and then keep tool bars hidden, or to force end edit when a move is detected (on element that is not current text).

BTW, great work ๐Ÿ‘

How to use this features in a function

func imagePickerController(_ picker: UIImagePickerController,
didFinishPickingMediaWithInfo info: [String : Any]) {

    guard let image = info[UIImagePickerControllerOriginalImage] as? UIImage else {
      //  picker.dismiss(animated: true, completion: nil)
        return
    }
    picker.dismiss(animated: true, completion: nil)
    
    
    let photoEditor = PhotoEditorViewController(nibName:"PhotoEditorViewController",bundle: Bundle(for: PhotoEditorViewController.self))
    photoEditor.photoEditorDelegate = self
    photoEditor.image = image
    //Colors for drawing and Text, If not set default values will be used
    //photoEditor.colors = [.red, .blue, .green]
    
    //Stickers that the user will choose from to add on the image
    for i in 0...10 {
        photoEditor.stickers.append(UIImage(named: i.description )!)
    }
    
    //To hide controls - array of enum control
    //photoEditor.hiddenControls = [.crop, .draw, .share]
    
    present(photoEditor, animated: true, completion: nil)
}

i want to execute this code in a function. how to do that.?

Need to Improve Documentation

there is older documents please update it.
this is not working
let photoEditor = UIStoryboard(name: "PhotoEditor", bundle: Bundle(for: PhotoEditorViewController.self)).instantiateViewController(withIdentifier: "PhotoEditorViewController") as! PhotoEditorViewController

Problem with pod

hi if i try to install it from pod
in the resource directory i see the xib file and not the storyboard
so the

let photoEditor = UIStoryboard(name: "PhotoEditor", bundle: Bundle(for: PhotoEditorViewController.self)).instantiateViewController(withIdentifier: "PhotoEditorViewController") as! PhotoEditorViewController

fail

Cancel share action

When Share action is canceled, show up the color picker (color circles for text) above bottom toolbar.
Tap share -> Select (TW, FB, Instagram....) -> Cancel
img_5215

Carthage

Hi, great library, It's possible implemented the Carthage ?

Issue while installing with Pods

Hi, Just now i've installed your photo-editor using cocoa pods, i'm getting errors.. Can you please help me to solve the issues. I'm using xcode 9.3 version
screen shot 2018-05-09 at 12 56 17 am

custom icons

Hi,

Is there any way to add our custom icons in the Editor view? Like Crop, Save.. etc

Fatal error: Unexpectedly found nil while unwrapping an Optional value

Can you give me a workaround for this? I tried copying icomoon.ttf into various places in the Pod/. but that did not help

func registerFont(){
    let bundle = Bundle(for: PhotoEditorViewController.self)
    let url =  bundle.url(forResource: "icomoon", withExtension: "ttf")

// Fatal error: Unexpectedly found nil while unwrapping an Optional value
guard let fontDataProvider = CGDataProvider(url: url! as CFURL) else {
return
}

not compatible with swift 4

I had some problems translating the photo-editor classes to swift 4
At the moment, when i draw in the image the lines fade and start to going up.

Carthage - no shared framework schemes

I'm trying to use Carthage however get the following error:

Dependency "photo-editor" has no shared framework schemes for any of the platforms: iOS

This may be the fix: [https://stackoverflow.com/a/35111518/1933346]

Bravo

Bravo ูŠุง ุญุงู…ุฏ ูˆุงู„ู„ู‡

Draws are "washed away" on certain photos.

I can't figure why, but if you draw on certain photos ( I just can't understand which is the criteria), the drawings become "wahsed away". The drawn lines fades away.

Is there a way to solve the problem?

No option for undo and redo?

There is No option for undo and redo, now we can clear all drawings the same time but need undo and redo option...?

is there possible to use alamofire for API calling

i am trying call api with alamofire on continueButton click in PhotoEditor+Controls.swift file but i am not able to import alamofile in PhotoEditor+Controls.swift file so is there any reason behind that why i am not able to import alamofire

Crop function: crash on iPad when opening the "constrain" alert sheet

Using the photo editor on the iPad, it will crash when trying to open the "constrain" alert sheet (in crop mode), because it does not have a barButtonItem or sourceRect/sourceView set.

Name: NSGenericException, Reason: Your application has presented a UIAlertController (<UIAlertController: 0x103ca6400>) of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.

Can be fixed by setting the appropriate barButtonItem in CropViewController.swift, before present is called (around line 239):

actionSheet.popoverPresentationController?.barButtonItem = sender

Exit Code 1 Error on load

I downloaded your code then installed the dependency iOSPhotoEditor in teh directory and I get this error:

Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

I steer anything I should do to run the example Photo Editor app ?

PhotoEditorViewController leaking memory via retain cycle

When you push the PhotoEditorViewController and finish, you can see in the Xcode memory guage that a huge amount of heap memory isn't getting released. Most likely due to the image.

Here i've edited 5 different photos, going back to the main screen each time (which should reset the heap) . You can see every time the heap increases but does not go down after popping:

image

Problems when using with ipad

fix bug in ipad

PhotoEditor+Controls.swift line at 88

@IBAction func shareButtonTapped(_ sender: UIButton) {
        //        let activity = UIActivityViewController(activityItems: [canvasView.toImage()], applicationActivities: nil)
        //        present(activity, animated: true, completion: nil)
        //
        print("shareButtonTapped")
        let objectsToShare = [canvasView.toImage()]
        let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
        activityVC.title = "Share One"
        activityVC.excludedActivityTypes = []
        
        activityVC.popoverPresentationController?.sourceView = self.view
        activityVC.popoverPresentationController?.sourceRect = sender.frame
        
        self.present(activityVC, animated: true, completion: nil)
        
    }

CropViewController.swift line at 148

func constrain(_ sender: UIBarButtonItem) {
        let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
        if let popoverController = actionSheet.popoverPresentationController {
            popoverController.barButtonItem = sender
            popoverController.permittedArrowDirections = .down
        }

iphone XR nodge

Hello,

when using an emulator or phone with notch display, the buttons are cut of from the notch.

guessing that you have to change the constrains to safe area.

thanks. J

Upload time is so long ?

Firstly thank you very much for this fantastic library to share.

Upload time is so long i'm showing spinner while it's uploading. but it is so boring.

min 7 - 8 max 12 second

if i take a picture without your library it just for one second..

Anything that i can to fix this situation ?

Suggestion

For the next update you guys should include a way to edit the font of text and the text's size similar to how you can change the color. Love the design!

Custom toolbar

Hello

Is it possible to define which elements in the top toolbar are shown and which are hidden ?

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.