{"id":13428798,"url":"https://github.com/the-super-toys/glimpse-android","last_synced_at":"2025-03-16T02:30:27.882Z","repository":{"id":45658572,"uuid":"169598303","full_name":"the-super-toys/glimpse-android","owner":"the-super-toys","description":"A content-aware cropping library for Android","archived":false,"fork":false,"pushed_at":"2020-02-02T11:04:54.000Z","size":19909,"stargazers_count":596,"open_issues_count":0,"forks_count":30,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-01-08T09:02:22.877Z","etag":null,"topics":["android","crop-image","machine-learning"],"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/the-super-toys.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-07T15:58:01.000Z","updated_at":"2024-11-29T16:25:00.000Z","dependencies_parsed_at":"2022-08-04T18:00:48.620Z","dependency_job_id":null,"html_url":"https://github.com/the-super-toys/glimpse-android","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-super-toys%2Fglimpse-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-super-toys%2Fglimpse-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-super-toys%2Fglimpse-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-super-toys%2Fglimpse-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/the-super-toys","download_url":"https://codeload.github.com/the-super-toys/glimpse-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243815569,"owners_count":20352192,"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","crop-image","machine-learning"],"created_at":"2024-07-31T01:01:05.415Z","updated_at":"2025-03-16T02:30:27.157Z","avatar_url":"https://github.com/the-super-toys.png","language":"Kotlin","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# Glimpse\n\nA content-aware cropping library for Android.\n\nGive the right first impression with just a glimpse! Instead of center cropping images blindly, leverage Glimpse's eye to catch the right spot.\n\n![image](doc_resources/glimpse_banner.png)\n\n## Setup\nAdd to top level *gradle.build* file\n```gradle\nallprojects {\n    repositories {\n        maven { url \"https://jitpack.io\" }\n    }\n}\n```\n\nAdd to app module *gradle.build* file\nTensorFlow lite recommends most developers omit the x86, x86_64, and arm32 ABIs. This can be achieved with the following Gradle configuration, which specifically includes only armeabi-v7a and arm64-v8a, which should cover most modern Android devices.\n```gradle\n\nandroid {\n    aaptOptions {\n        noCompress \"tflite\"\n        noCompress \"lite\"\n    }\n    defaultConfig {\n        ndk {\n            abiFilters 'armeabi-v7a', 'arm64-v8a'\n        }\n    }\n}\n\ndependencies {\n    implementation 'com.github.the-super-toys.glimpse-android:glimpse-core:0.0.5'\n    \n    //only required for glide extensions\n    implementation 'com.github.the-super-toys.glimpse-android:glimpse-glide:0.0.5'\n    \n    //only required for coil extensions\n    implementation 'com.github.the-super-toys.glimpse-android:glimpse-coil:0.0.5'\n    \n    implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly'\n}\n```\n\n## Usage\n\n### Init Glimpse in your Android app\n\n```kotlin\nclass YourApp : Application() {\n    override fun onCreate() {\n        super.onCreate()\n        Glimpse.init(this)\n    }\n}\n```\n\n### Use Glimpse without extensions\nFirst compute image's focal points by calling `Bitmap.findCenter` extension function.\n\n```kotlin\nval original = (imageView.drawable as BitmapDrawable).bitmap\nval (x, y) = original.findCenter()\n```\n\nThen supply those focal points alongside with the width and height values of the target `ImageView` to `Bitmap.crop` extension function.\n\n```kotlin\nval cropped = original.crop(x, y, imageView.layoutParams.width, imageView.layoutParams.height)\nimageView.setImageBitmap(cropped)\n```\n\n### Use Glimpse with Glide extension \nIf you are using [Glide](https://github.com/bumptech/glide) for image loading you can just add `GlimpseTransformation` to `GlideRequest` builder:\n\n \n```kotlin\nGlideApp.with(context)\n                .load(url)\n                .diskCacheStrategy(DiskCacheStrategy.RESOURCE)\n                .transform(GlimpseTransformation())\n                .into(imageView)\n```\n\nIt is recommended to set `diskCacheStrategy(DiskCacheStrategy.RESOURCE)` to cache the cropped bitmap by Glimpse, otherwise focal points will be calculated every time the image is displayed.\n\n\n### Use Glimpse with Coil extension \nIf you are using [Coil](https://github.com/coil-kt/coil) for image loading you can just add `GlimpseTransformation` to Coil's `LoadRequestBuilder` builder:\n\n \n```kotlin\nimageView.load(url) {\n    crossfade(true)\n    placeholder(R.drawable.image)\n    transformations(GlimpseTransformation())\n}\n\n\n```\n\n### What about other image loaders such as Picasso and Fresco?\n\nWe tried to ship Glimpse with both Picasso and Fresco extensions but we were not able to find the right api.\n\nWe opened an [issue on Picasso repository](https://github.com/square/picasso/issues/2067) and a [labeled Fresco question on Stack Overflow](https://stackoverflow.com/questions/54773198/fresco-how-to-use-scaletypes-focuscrop-based-on-bitmap-content)  asking for guidance, but sadly we did not find much support. If you know how to assemble Glimpse cropping functionality to either lib without disrupting their original pipeline, please open an issue to review together the proposal. We really want to offer support for all the popular loading image libraries!  \n  \n### Java callers\nIf you're using Java you can take a look at this [file](https://github.com/the-super-toys/glimpse-android/blob/master/sample-app/src/main/java/glimpse/sample/TestingApiFromJava.java) to see how Glimpse api looks for Java callers. \n\n## Sample app\n`:sample-app` module showcase Glimpse usage by making use of Glide extensions. The application is also published on [Google Play](https://play.google.com/store/apps/details?id=glimpse.sample). \n\n\n## Is Glimpse ready for production? \n\nActually, it depends. Ideally you should not use Glimpse to crop the same image over and over. Even if you use Glide extension which caches the output transformation, the underlying calculation \nwill be performed in every android client. Thus, if possible, send to your cloud solution the x and y focal points of the calculated crop alongside the image when user uploads content.\n\nWe timed the crop calculation on an OnePlus 6 and in average it takes 30 milliseconds. Depending on the device and your specific use case Glimpse may or may not be ready for production. In any case we encourage you to provide feedback to help us make Glimpse a mature library.\n\n\n## How much increase APK's size?\n\nIf you're already using [TensorFlow lite](https://www.tensorflow.org/lite) in your app, adding Glimpse costs only the size of the model, which is 148 KB. But chances are that you are not using it, so you have to take into account also the size of [TensorFlow lite](https://www.tensorflow.org/lite/overview#tensorflow_lite_highlights), which is about 300 KB.\n\n\n## Let's go DEEPER (The Deep Learning Model)\n\nIf you want to know how Glimpse works in a more deeper lever, take a look at [this repository](https://github.com/the-super-toys/glimpse-models), where you can see the architecture and implementation of the Deep Learning model used by Glimpse. We explain how everything works in a much more technical level, and with all details, so you can reproduce it on your own, and improve it if you want.  \n\nBut if you do, don't hesitate to submit a Pull Request to that repository so we can keep improving Glimpse!!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-super-toys%2Fglimpse-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthe-super-toys%2Fglimpse-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-super-toys%2Fglimpse-android/lists"}