{"id":15031223,"url":"https://github.com/redapparat/fotoapparat","last_synced_at":"2025-05-14T02:00:34.343Z","repository":{"id":41280888,"uuid":"85997051","full_name":"RedApparat/Fotoapparat","owner":"RedApparat","description":"Making Camera for Android more friendly. 📸","archived":false,"fork":false,"pushed_at":"2023-10-26T03:07:30.000Z","size":1405,"stargazers_count":3829,"open_issues_count":87,"forks_count":411,"subscribers_count":90,"default_branch":"master","last_synced_at":"2025-05-07T05:54:47.323Z","etag":null,"topics":["android","camera"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RedApparat.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":"2017-03-23T20:59:37.000Z","updated_at":"2025-05-06T22:28:30.000Z","dependencies_parsed_at":"2022-07-14T11:30:47.304Z","dependency_job_id":"df229cbe-172e-46b6-9dd0-a7caa7c529da","html_url":"https://github.com/RedApparat/Fotoapparat","commit_stats":{"total_commits":563,"total_committers":37,"mean_commits":"15.216216216216216","dds":0.5150976909413854,"last_synced_commit":"9454f3e4d1d222799049b00f3d84b274c3e02ee6"},"previous_names":["fotoapparat/fotoapparat"],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedApparat%2FFotoapparat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedApparat%2FFotoapparat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedApparat%2FFotoapparat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedApparat%2FFotoapparat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RedApparat","download_url":"https://codeload.github.com/RedApparat/Fotoapparat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254052658,"owners_count":22006716,"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":["android","camera"],"created_at":"2024-09-24T20:15:11.916Z","updated_at":"2025-05-14T02:00:34.269Z","avatar_url":"https://github.com/RedApparat.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fotoapparat\n\n![Build status](https://travis-ci.org/RedApparat/Fotoapparat.svg?branch=master)\n\n![ ](sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png)\n\nCamera API in Android is hard. Having 2 different API for new and old Camera does not make things any easier. But fret not, that is your lucky day! After several years of working with Camera, we came up with Fotoapparat.\n\nWhat it provides:\n\n- Camera API which does not allow you to shoot yourself in the foot.\n- Simple yet powerful parameters customization.\n- Standalone custom `CameraView` which can be integrated into any `Activity`.\n- Fixes and workarounds for device-specific problems.\n- Both Kotlin and Java friendly configurations.\n- Last, but not least, non 0% test coverage.\n\nTaking picture becomes as simple as:\n\n```kotlin\nval fotoapparat = Fotoapparat(\n    context = this,\n    view = cameraView\n)\n\nfotoapparat.start()\n\nfotoapparat\n    .takePicture()\n    .saveToFile(someFile)\n```\n\n## How it works\n\n### Step One\n\nAdd `CameraView` to your layout\n\n```xml\n\u003cio.fotoapparat.view.CameraView\n    android:id=\"@+id/camera_view\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"/\u003e\n```\n\n### Step Two\n\nConfigure `Fotoapparat` instance.\n\n```kotlin\nFotoapparat(\n            context = this,\n            view = cameraView,                   // view which will draw the camera preview\n            scaleType = ScaleType.CenterCrop,    // (optional) we want the preview to fill the view\n            lensPosition = back(),               // (optional) we want back camera\n            cameraConfiguration = configuration, // (optional) define an advanced configuration\n            logger = loggers(                    // (optional) we want to log camera events in 2 places at once\n                     logcat(),                   // ... in logcat\n                     fileLogger(this)            // ... and to file\n            ),\n            cameraErrorCallback = { error -\u003e }   // (optional) log fatal errors\n    )\n```\n\nCheck the [wiki for the `configuration` options e.g. change iso](https://github.com/Fotoapparat/Fotoapparat/wiki/Configuration-Kotlin)\n\nAre you using Java only? See our [wiki for the java-friendly configuration](https://github.com/Fotoapparat/Fotoapparat/wiki/Configuration-Java).\n\n### Step Three\n\nCall `start()` and `stop()`. No rocket science here.\n\n```kotlin\noverride fun onStart() {\n    super.onStart()\n    fotoapparat.start()\n}\n\noverride fun onStop() {\n    super.onStop()\n    fotoapparat.stop()\n}\n```\n\n### Take a picture\n\nFinally, we are ready to take a picture. You have various options.\n\n```kotlin\nval photoResult = fotoapparat.takePicture()\n\n// Asynchronously saves photo to file\nphotoResult.saveToFile(someFile)\n\n// Asynchronously converts photo to bitmap and returns the result on the main thread\nphotoResult\n    .toBitmap()\n    .whenAvailable { bitmapPhoto -\u003e\n            val imageView = (ImageView) findViewById(R.id.result)\n\n            imageView.setImageBitmap(bitmapPhoto.bitmap)\n            imageView.setRotation(-bitmapPhoto.rotationDegrees)\n    }\n\n// Of course, you can also get a photo in a blocking way. Do not do it on the main thread though.\nval result = photoResult.toBitmap().await()\n\n// Convert asynchronous events to RxJava 1.x/2.x types.\n// See /fotoapparat-adapters/ module\nphotoResult\n        .toBitmap()\n        .toSingle()\n        .subscribe { bitmapPhoto -\u003e\n\n        }\n```\n\n## Update parameters\n\nIt is also possible to update some parameters after `Fotoapparat` was already started.\n\n```kotlin\nfotoapparat.updateConfiguration(\n        UpdateConfiguration(\n                flashMode = if (isChecked) torch() else off()\n                // ...\n                // all the parameters available in CameraConfiguration\n        )\n)\n```\n\nOr alternatively, you may provide updates on an existing full configuration.\n\n```kotlin\nval configuration = CameraConfiguration(\n    // A full configuration\n    // ...\n)\n\nfotoapparat.updateConfiguration(\n    configuration.copy(\n            flashMode = if (isChecked) torch() else off()\n            // all the parameters available in CameraConfiguration\n    )\n)\n```\n\n## Switch cameras\n\nIn order to switch between cameras, `Fotoapparat.switchTo()` can be used with the new desired `lensPosition` and its `cameraConfiguration`.\n\n```kotlin\nfotoapparat.switchTo(\n    lensPosition = front(),\n    cameraConfiguration = newConfigurationForFrontCamera\n)\n```\n\n## Set up\n\nAdd dependency to your `build.gradle`\n\n```groovy\nimplementation 'io.fotoapparat:fotoapparat:2.7.0'\n```\n\nCamera permission will be automatically added to your `AndroidManifest.xml`. Do not forget to request this permission on Marshmallow and higher.\n\n## Face detection\n\nOptionally, you can check out our other library which adds face detection capabilities - [FaceDetector](https://github.com/Fotoapparat/FaceDetector).\n\n## Credits\n\nWe want to say thanks to [Mark Murphy](https://github.com/commonsguy) for the awesome job he did with [CWAC-Camera](https://github.com/commonsguy/cwac-camera). We were using his library for a couple of years and now we feel that Fotoapparat is a next step in the right direction.\n\nWe also want to say many thanks to [Leander Lenzing](http://leanderlenzing.com/) for the amazing icon. Don't forget to follow his work in [dribbble](https://dribbble.com/leanderlenzing).\n\n## License\n\n```\nCopyright 2017 Fotoapparat\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredapparat%2Ffotoapparat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredapparat%2Ffotoapparat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredapparat%2Ffotoapparat/lists"}