Code Monkey home page Code Monkey logo

kanvas-ios's Introduction

kanvy

Kanvas

Build status

Cocoapods

Kanvas is an open-source iOS library for adding effects, drawings, text, stickers, and making GIFs from existing media or the camera.

It is used in the Tumblr iOS app as a camera, media editor, GIF maker, and media posting tool.

Setup

Add this to your Podfile:

pod 'Kanvas', :git => 'https://github.com/tumblr/kanvas-ios.git'

And run:

pod install

Usage

Kanvas is mainly two parts: the Camera, and the Editor. Both are just view controllers that you present, and have settings and delegates that help you customize their behavior.

To show the camera:

let settings = CameraSettings()
let camera = CameraController(settings: settings)
present(camera, animated: true)

And to edit existing media, like a video:

let videoURL = URL(string: "path/to/video.mov")
let settings = CameraSettings()
let editor = EditorViewController.createEditor(for: videoURL, settings: settings)
present(editor, animated: true)

Each view controller accepts a CameraSettings object, which provides fine-grained settings and feature togges. Each view controller also has a delegate property for providing your own handlers to creating media, performing editing operations, logging, or really anything else Kanvas can do.

Documentation is lacking at the moment, but contributions are welcome!

Example App

Example is an example app showing how to use Kanvas. Try it out!

  1. Run cd Example; bundle exec pod install
  2. Open Example/KanvasExample.xcworkspace in Xcode
  3. Run the app on a device.

kanvas-ios's People

Contributors

adriana-elizondo avatar afterxleep avatar andrewdmontgomery avatar benjamin-su avatar bjtitus avatar ctarda avatar danielebogo avatar deco354 avatar etoledom avatar gmazzei avatar jkmassel avatar jschementi avatar krze avatar lucaslimapoa avatar mindgraffiti avatar mokagio avatar nghialuong avatar pinarol avatar rafaelkayumov avatar sergioestevao avatar staskus avatar taichino avatar twstokes 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

kanvas-ios's Issues

Deleting a single slide shouldn't exit the story creation mode

What happens:

  1. Take a photo/video or select a photo to add
  2. Drag the thumbnail to delete it
  3. Kanvas closes and you return the main WP view

What I expected:

  1. Take a photo/video or select a photo to add
  2. Drag the thumbnail to delete it
  3. Return to the camera capture view to take a new photo or select a new photo

Landscape device-orientation

Allow Kanvas to support the landscape device-orientation, so landscape media would fit better on the screen, and the camera would shoot landscape-oriented media.

Also, if we can adjust to a dynamically-changing screen size, this would also allow us to support the iPad.

Add logging to permission view

We should add the following logging methods to KanvasCameraAnalyticsProvider and call them at the appropriate times:

  • logCameraPermissionView
  • logMicrophoneAccessInitiated
  • logCameraAccessInitiated
  • logMediaPickerOpen
  • logMicrophoneAccess(notDetermined|restricted|denied|authorized)
  • logCameraAccess(notDetermined|restricted|denied|authorized)
  • logMediaPickerAccess(notDetermined|limited|restricted|denied|authorized)

Animated Stickers

Support GIF stickers.

For photos, the photo will be converted to a video of a set duration, and the sticker will loop over that.

For GIFs or videos, the sticker will just loop over the video.

The permissions screen buttons do not work after revoking manually

  • Accept permissions when first using
  • Go back to the Privacy screen in settings and disable camera and microphone access
  • Go back to create with Kanvas
  • The "Allow access to camera/microphone" buttons do not work

We probably need to show better messaging here as I don't think it's possible to enable the in-app after they have been manually disabled.

Re-enable `MediaPlayerTests.testPlayVideo()` on CircleCI

The MediaPlayerTests.testPlayVideo() method fails run run on CircleCI:

Test Case '-[KanvasCameraExampleTests.MediaPlayerTests testPlayVideo]' started.
2020-10-27 01:10:30.268425+0000 KanvasCameraExample[1467:68019] [aqme] AQMEIO.cpp:352:AQMEIOManager_FindIOUnit: error -66680 finding/initializing Device.AQDefaultDevice
2020-10-27 01:10:30.268629+0000 KanvasCameraExample[1467:68019] [aqme] AQMEIO.cpp:352:AQMEIOManager_FindIOUnit: error -66680 finding/initializing Device.AQDefaultDevice
2020-10-27 01:10:30.268791+0000 KanvasCameraExample[1467:68019] [aqme] AQMEIO.cpp:352:AQMEIOManager_FindIOUnit: error -66680 finding/initializing Device.AQDefaultDevice
2020-10-27 01:10:30.268965+0000 KanvasCameraExample[1467:68019] [aqme] AQMEIO.cpp:352:AQMEIOManager_FindIOUnit: error -66680 finding/initializing Device.AQDefaultDevice
2020-10-27 01:10:30.269141+0000 KanvasCameraExample[1467:68019] [aqme] AQMEIO.cpp:352:AQMEIOManager_FindIOUnit: error -66680 finding/initializing Device.AQDefaultDevice
2020-10-27 01:10:30.269486+0000 KanvasCameraExample[1467:68019]  AudioObjectRemovePropertyListener: no object with given ID 0
2020-10-27 01:10:30.269625+0000 KanvasCameraExample[1467:68019]  AudioObjectRemovePropertyListener: no object with given ID 0
2020-10-27 01:10:30.269743+0000 KanvasCameraExample[1467:68019]  AudioObjectRemovePropertyListener: no object with given ID 0

Restarting after unexpected exit, crash, or test timeout in MediaPlayerTests/testPlayVideo(); summary will include totals from previous launches.

Allow Stitch mode to capture an unlimited number of media

Currently, Stitch mode will store captured media on disk, but the thumbnail is stored in memory. This means we could run out of memory if someone captured a large number of images or videos.

The thumbnails should be on disk also, and we should make sure that they are loaded out of memory as the corresponding cell in the clips list goes off-screen.

Allow the camera to work without microphone access

Right now we block the camera from being used until you grant microphone and camera access.

Instead, we could just require one of them, and respond accordingly:

  • Just microphone access would show an audio-only recorder
  • Just camera access would still record video, just without audio

In both cases, we'd have to show that we're missing the other permission, and provide a way to navigate to System Settings to enable it.

GIFEncoderTests fails sometimes

This test failed routinely when running in Tumblr's CI, but not sure about CircleCI. Regardless, we should make sure this test is sound and enable it.

Audio toggle for video

We'll want to add an sound on / off toggle button on video slides so the user can turn audio off for a video.

Re-enable `FilteredInputViewControllerTests.testFilteredInputView` test

The FilteredInputViewControllerTests.testFilteredInputView fails to run on CircleCI:

Test Case '-[KanvasCameraExampleTests.FilteredInputViewControllerTests testFilteredInputView]' started.
Fatal error: Failed to create MetalContext: file KanvasCamera/FilteredInputViewController.swift, line 25
2020-10-27 01:10:02.339476+0000 KanvasCameraExample[1452:62258] Fatal error: Failed to create MetalContext: file KanvasCamera/FilteredInputViewController.swift, line 25

Restarting after unexpected exit, crash, or test timeout in FilteredInputViewControllerTests/testFilteredInputView(); summary will include totals from previous launches.

Toggle between exporting at the media-resolution or the screen-aspect-ratio

Currently all media is exported as its original resolution. While that works great most of the time, someone might want to zoom in on a landscape photo and just use a portion.

Let's add a screen-aspect-ratio mode which allows you to position the media inside the screen as you see fit, and choose a background style (color/gradient/blur).

Create a Sticker

A user can create a sticker by tapping a button in the sticker drawer, which will open a new instance of the Camera, allowing them to either capture media or pick it with the media player, and send them to the Editor. However, instead of posting, the next screen will let them cut out the sticker, either with a few preset shapes (circle, square, quote) or freeform. The user can then confirm the sticker, and it's added to their sticker drawer. This will only be persisted in the app.

Fix or remove "Open Kanvas Dashboard" from Example App

"Open Kanvas Dashboard" is meant to mimic a swipe-to-open interface, which would be useful to have, but this one crashes on the 2nd open, and the code it's based on is now significantly different in Orangina, so might as well just make one from scratch here, or totally remove it.

Enable the media picker in Stitch mode

Right now Stitch mode just let's you use the camera.

Let's enable the media picker for Stitch mode. The final media should be the resolution of the first image, and the remaining images should be aspect-fit inside that, with the negative space being the image aspect-filled, but blurred.

Notify when Kanvas doesn't have Photo Library access

Currently, if someone denies Photo Library access, we'll just don't save media to their Photo Library, but we will still call didCreateMedia to allow the host to use the media.

It'd be nice in the Editor to somehow indicate (in a non-blocking way) that they've denied this permission, and link them to Settings to enable it if they choose.

Display predictive text above keyboard

I expected to have access to the predictive text options that are usually displayed above the keyboard. (I've come to rely on them too much.)

Also noticed they aren't displayed above the keyboard in the publish sheet. I'd expect to have them there too.

Video output is rotated

Testing 16.3 (39815)

Videos in this story are rotated 90 degrees counter clockwise. They're both portrait videos that appeared right in the editing view.

Screen Shot 2021-01-06 at 11 31 34 AM

s/KanvasCamera/Kanvas

The pod should be named Kanvas and the framework should be called Kanvas. This project is not just a camera, so let's have the name reflect that.

Decide on sticker library

Where do the stickers in Tumblr come from? Is it a custom library? Or sourced from a third party?

Could we easily reuse the UI here to show the device emoji library?

Font toggle not working in 35257 build

Noticed in the 35257 build that you can't toggle to change the font between the sans serif and the script. This button works in the regular tumblr build.

Handling images / video selected from device photos

Current behavior:
Both landscape and portrait media is scaled to fit the width of the screen.

Options for discussion:

  1. Automatically scale the media to fit the full height of the screen for portrait images. Continue scaling to fit the width for landscape.
  2. Allow for manipulation of the background image so user can scale and crop.
  3. Something else?

Support Stitch mode with different media resolutions

Right now, if Stitch mode allows using media with different resolutions, there's some problems:

  1. The preview skips clip that's are a different resolution than the first clip.
  2. The output stretches all clips to be the size of the first clip.

Ideally we'd have the output media be the resolution of the first media, and subsequent media gets centered and aspect-filled.

A way to switch out of Stitch mode without deleting all Stitch clips

Right now, you have to drag each clip you've captured in Stitch mode to the trash to switch to another camera mode.

There should be a way to switch modes without needing to delete each clip individually. Either a way to delete all the clips quickly, or, preserve stitch clips.

Convert to GIF in the background

Currently the GIF maker converts the entire video to a GIF, even though we only export max-3 seconds. While this works for shorter videos, long videos can take very long to convert, and we have to do it at a poor quality.

Instead, the GIF maker should work against the video itself for seeking and such, but in the background convert it to a GIF at a good quality. When the conversion is complete, it should swap the media out so it plays back the GIF.

Playback modes like rebound/reverse won't work against the video, but that's OK.

When swapping the video and GIF, playback should be seamless, and not restart.

(Having this setup this way will allow us to just use the trimmer for videos too!)

Camera viewport misalignment when using Metal

When enabling Metal for the rendering pipeline, the camera viewport is not centered:

OpenGL Metal

This is most likely due to the camera viewport cropping that happens in OpenGL to ensure camera-captured media has the same aspect ratio as the screen.

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.