{"id":17923154,"url":"https://github.com/rogerluan/swiftttcamera","last_synced_at":"2025-08-10T22:40:34.238Z","repository":{"id":63920417,"uuid":"399295331","full_name":"rogerluan/SwiftttCamera","owner":"rogerluan","description":"Swifttty and easy camera framework for iOS.","archived":false,"fork":false,"pushed_at":"2023-04-11T20:36:58.000Z","size":1743,"stargazers_count":19,"open_issues_count":2,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-03-14T20:20:13.867Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rogerluan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-24T01:19:18.000Z","updated_at":"2023-10-23T09:01:44.000Z","dependencies_parsed_at":"2024-10-28T20:52:23.522Z","dependency_job_id":null,"html_url":"https://github.com/rogerluan/SwiftttCamera","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"8c418c68a20b990c94644add4906d74d94592a80"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogerluan%2FSwiftttCamera","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogerluan%2FSwiftttCamera/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogerluan%2FSwiftttCamera/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogerluan%2FSwiftttCamera/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rogerluan","download_url":"https://codeload.github.com/rogerluan/SwiftttCamera/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234687377,"owners_count":18871738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-28T20:42:20.574Z","updated_at":"2025-01-19T19:32:21.200Z","avatar_url":"https://github.com/rogerluan.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg width=250 src=\".github/docs/logo.png\"\u003e\n  \u003ch1\u003eSwiftttCamera\u003c/h1\u003e\n  \u003cp\u003e\u003cstrong\u003eSwifttty and easy camera framework for iOS.\u003c/strong\u003e\u003c/p\u003e\n\n  \u003ca href=\"https://github.com/rogerluan/SwiftttCamera/actions/workflows/run_tests.yml\"\u003e\n    \u003cimg src=\"https://github.com/rogerluan/SwiftttCamera/workflows/Run%20Tests/badge.svg\" alt=\"GitHub Action Build Status\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://swift.org\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Swift-5.4-F05138?logo=swift\u0026logoColor=white\" alt=\"Swift 5.4\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://github.com/rogerluan/SwiftttCamera/releases/latest\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/release/rogerluan/SwiftttCamera?sort=semver\" alt=\"Latest release\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://codeclimate.com/github/rogerluan/SwiftttCamera/maintainability\"\u003e\u003cimg src=\"https://api.codeclimate.com/v1/badges/494f54ae866f5e38a66e/maintainability\" /\u003e\u003c/a\u003e\n\n  \u003ca href=\"https://github.com/rogerluan/SwiftttCamera/issues\"\u003e\n    \u003cimg alt=\"Issues\" src=\"https://img.shields.io/github/issues/rogerluan/SwiftttCamera?color=#86D492\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://twitter.com/intent/follow?screen_name=rogerluan_\"\u003e\n    \u003cimg src=\"https://img.shields.io/twitter/follow/rogerluan_?\u0026logo=twitter\" alt=\"Follow on Twitter\"\u003e\n  \u003c/a\u003e\n\n  \u003cp align=\"center\"\u003e\n    \u003ca href=\"#demo\"\u003eView Demo\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/rogerluan/SwiftttCamera/issues/new/choose\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/rogerluan/SwiftttCamera/issues/new/choose\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n`SwiftttCamera` is a wrapper around `AVFoundation` that allows you to build your own powerful custom camera app without all the headaches of using `AVFoundation` directly.\n\n## Why use this?\n\n#### Major headaches that `SwiftttCamera` automatically handles for you:\n\n##### `AVFoundation` Headaches\n\n* Configuring and managing an `AVCaptureSession`.\n* Displaying the `AVCaptureVideoPreviewLayer` in a sane way relative to your camera's view.\n* Configuring the state of the `AVCaptureDevice` and safely changing its properties as needed, such as setting the flash mode and switching between the front and back cameras.\n* Adjusting the camera's focus and exposure in response to tap gestures.\n* Zooming the camera in response to pinch gestures.\n* Capturing a full-resolution photo from the `AVCapturePhotoOutput`.\n\n##### Device Orientation Headaches\n\n* Changing the `AVCaptureConnection`'s orientation appropriately when the device is rotated.\n* Detecting the actual orientation of the device when a photo is taken _even if orientation lock is on_ by using the accelerometer, so that landscape photos are always rotated correctly.\n* _(Optional)_ Returning a preview version of the image rotated to match the orientation of what was displayed by the camera preview, even if the user has orientation lock on.\n* _(Optional)_ Asynchronously returning an orientation-normalized version of the captured image rotated so that the image orientation is always `UIImage.Orientation.up`, useful for reliably displaying images correctly on web services that might not respect EXIF image orientation tags.\n\n##### Image Processing Headaches\n\n* _(Optional)_ Cropping the captured image to the visible bounds of your camera's view.\n* _(Optional)_ Returning a scaled-down version of the captured image.\n* Processing high-resolution images quickly and efficiently without overloading the device's memory or creating app-terminating memory leaks.\n\n`SwiftttCamera` does many operations faster than `UIImagePickerController`'s camera, such as switching between the front and back camera, and provides you the captured photos in the format you need, returning a cropped full-resolution image as quickly as `UIImagePickerController` returns the raw captured image on most devices. It allows all of the flexibility of `AVFoundation` without the need to reinvent the wheel, so you can focus on making a beautiful custom UI and doing awesome things with photos.\n\nWhile both `UIImagePickerController`'s camera and `AVFoundation` give you raw images that may not even be cropped the same as the live camera preview your users see, `SwiftttCamera` gives you a full-resolution image cropped to the same aspect ratio as your live preview's viewport as well as a preview image scaled to the pixel dimensions of that viewport, whether you want a square camera, a camera sized to the full screen, or something else.\n\n`SwiftttCamera` is also smart at handling image orientation, a notoriously tricky part of images from both `AVFoundation` and `UIImagePickerController`. The orientation of the camera is magically detected correctly even if the user is taking landscape photos with orientation lock turned on, because `SwiftttCamera` checks the accelerometer to determine the real device orientation.\n\n## Installation\n\n`SwiftttCamera` is available through Swift Package Manager:\n\n```\ndependencies: [\n    .package(name: \"SwiftttCamera\", url: \"https://github.com/rogerluan/SwiftttCamera\", .upToNextMajor(from: \"1.0.0\")),\n]\n```\n\n## Demo\n\nTo run the demo project, clone or download the repo, and open \u003ckbd\u003eSwiftttCameraDemo/SwiftttCameraDemo.xcodeproj\u003c/kbd\u003e\n\nSwiftttCamera Benchmark|UIImagePickerController Benchmark\n--|--\n\u003cimg width=\"210\" alt=\"SwiftttCamera Benchmark Average Run Time\" src=\".github/docs/swiftttcamera-benchmark.jpg\"\u003e|\u003cimg width=\"210\" alt=\"UIImagePickerController Benchmark Average Run Time\" src=\".github/docs/uiimagepickercontroller-benchmark.jpg\"\u003e\n\n## Usage\n\nAdd an instance of `SwiftttCamera` as a child of your view controller. Adjust the size and layout of `SwiftttCamera`'s view however you'd like, and `SwiftttCamera` will automatically adjust the camera's preview window and crop captured images to match what is visible within its bounds.\n\n```swift\nimport SwiftttCamera\nimport UIKit\n\nclass DemoViewController : UIViewController {\n    private lazy var camera: SwiftttCamera = {\n        let result = SwiftttCamera()\n        result.delegate = self\n        result.view.translatesAutoresizingMaskIntoConstraints = false\n        return result\n    }()\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n        swiftttAddChild(camera)\n        camera.view.frame = view.frame // Alternatively, you can set it up using autolayout\n    }\n}\n\nextension DemoViewController : CameraDelegate {\n    func cameraController(_ cameraController: CameraProtocol, didFinishCapturingImage capturedImage: CapturedImage) {\n        // Handle the captured image\n    }\n}\n```\n\nSwitch between the front and back cameras:\n\n```swift\nlet newCameraDevice: CameraDevice = camera.cameraDevice.toggling()\nguard SwiftttCamera.isCameraDeviceAvailable(newCameraDevice) else { return }\ncamera.cameraDevice = newCameraDevice\n```\n\nSet the camera's flash mode:\n\n```swift\ncamera.cameraFlashMode = shouldEnable ? .on : .off\n```\n\nSet the camera's torch mode:\n\n```swift\nlet shouldEnable = enabled \u0026\u0026 camera.isTorchAvailableForCurrentDevice\ncamera.cameraTorchMode = shouldEnable ? .on : .off\n```\n\nTake a picture:\n\n```swift\ncamera.takePicture()\n```\n\nUse `SwiftttCamera`'s delegate methods to retrieve the captured image object after taking a photo:\n\n```swift\nfunc cameraController(_ cameraController: CameraProtocol, didFinishCapturingImage capturedImage: CapturedImage) {\n    // Optional protocol function\n}\n\nfunc cameraController(_ cameraController: CameraProtocol, didFinishScalingCapturedImage capturedImage: CapturedImage) {\n    // Optional protocol function\n}\n\nfunc cameraController(_ cameraController: CameraProtocol, didFinishNormalizingCapturedImage capturedImage: CapturedImage) {\n    // Optional protocol function\n}\n```\n\n# References\n\nThis project is strongly based off of [FastttCamera](https://github.com/IFTTT/FastttCamera), but since that project hasn't been maintained since 2016, this project aims to give life back to that awesome framework, with the same perks, but using more modern APIs, and limiting supported SDKs to iOS 13+ only. Huge thanks [Laura Skelton](https://github.com/lauraskelton), the creator of `FastttCamera` for creating such awesome project. Without her work, this project definitely wouldn't be possible. 💪\n\n# Contributions\n\nIf you spot something wrong, missing, or if you'd like to propose improvements to this project, please open an Issue or a Pull Request with your ideas and I promise to get back to you within 24 hours! 😇\n\n# License\n\nThis project is open source and covered by a standard 2-clause BSD license. That means you can use (publicly, commercially and privately), modify and distribute this project's content, as long as you mention *Roger Oba* as the original author of this code and reproduce the LICENSE text inside your app, repository, project or research paper.\n\n# Contact\n\nTwitter: [@rogerluan_](https://twitter.com/rogerluan_)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogerluan%2Fswiftttcamera","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frogerluan%2Fswiftttcamera","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogerluan%2Fswiftttcamera/lists"}