
AI-powered image filtering library detects and blurs inappropriate content, ensuring respectful and culturally appropriate visuals, particularly aligned with Islamic values. Offers customizable blur strength.
Safe Image is an AI-powered image filtering library designed to promote safe and culturally appropriate content.
The library uses advanced deep learning models to automatically detect and blur inappropriate or sensitive content in images, with full control over the blur strength, ensuring that visuals remain respectful and aligned with Islamic values.
Make sure Maven Central is added to your project-level build.gradle (or settings.gradle for Gradle 7+):
repositories {
google()
mavenCentral()
}Add Safe Image in module-level build.gradle:
dependencies {
implementation("io.github.devvura:safe-image-compose:1.0.0")
}
If you only want to display an image with automatic blurring, you can use SafelImage with just the model parameter:
SafeImage(
model = "https://example.com/sample.jpg",
contentDescription = "Sample Image"
)You can fully customize SafeImage by providing parameters such as loadingContent, errorContent, onBlurContent, blurRadius, and more:
SafeImage(
modifier = Modifier.fillMaxWidth(),
model = "https://example.com/sample.jpg",
contentDescription = "Sample Image",
loadingContent = { Text(text = "Loading...") },
errorContent = { Text(text = "Error loading image") },
onBlurContent = { Text(text = "Sensitive content")},
blurRadius = 20,
contentScale = ContentScale.FillWidth
)| Parameter | Type | Default | Description |
|---|---|---|---|
model |
Any |
— | The image source (URL, file, resource, etc.) |
contentDescription |
String? |
null |
Description for accessibility (screen readers) |
modifier |
Modifier |
Modifier |
Layout styling (size, padding, etc.) |
loadingContent |
@Composable () -> Unit |
null |
UI to display while the image is loading |
errorContent |
@Composable () -> Unit |
null |
UI to display if loading fails |
onBlurContent |
@Composable () -> Unit |
null |
UI overlay shown when inappropriate content is blurred |
blurRadius |
Int |
16 |
Blur strength applied to blurred images |
contentScale |
ContentScale |
ContentScale.Crop |
Defines how the image should scale inside its container |
Add Safe Image in module-level build.gradle:
dependencies {
implementation("io.github.devvura:safe-image:1.0.0")
}
If you only want to display an image with automatic blurring, you can use SafeImage with just the model parameter:
val imageView = findViewById<ImageView>(R.id.imageView1)
imageView.loadSafeImage(
model = "https://example.com/sample.jpg",
placeholderRes = R.drawable.loading_bar,
errorDrawableRes = R.drawable.error_svgrepo_com
)You can fully customize SafeImage by providing parameters such as onLoading, onError, blurRadius, and more:
val imageView = findViewById<ImageView>(R.id.imageView1)
imageView.loadSafeImage(
model = "https://example.com/sample.jpg",
blurRadius = 70,
onLoading = {
Toast.makeText(context, "Loading image...", Toast.LENGTH_SHORT).show()
},
onError = {
Toast.makeText(context, "Failed to load image", Toast.LENGTH_SHORT).show()
},
onSuccess = {
Toast.makeText(context, "Image loaded successfully!", Toast.LENGTH_SHORT).show()
},
crossFadeEnabled = true,
placeholderRes = R.drawable.loading_bar,
errorDrawableRes = R.drawable.error_svgrepo_com
)| Parameter | Type | Default | Description |
|---|---|---|---|
model |
Any |
— | The image source (URL, file, resource, etc.) |
blurRadius |
Int |
50 |
Blur strength in pixels |
onLoading |
(() -> Unit)? |
null |
Callback triggered when image starts loading |
onError |
(() -> Unit)? |
null |
Callback triggered if image loading fails |
onSuccess |
(() -> Unit)? |
null |
Callback triggered when image loads successfully |
crossFadeEnabled |
Boolean |
true |
Enables smooth crossfade animation between placeholder and image |
placeholderRes |
@DrawableRes Int? |
null |
Drawable resource displayed while loading |
errorDrawableRes |
@DrawableRes Int? |
null |
Drawable resource displayed on error |
Safe Image integrates seamlessly with Coil’s image loading pipeline, working specifically on the Transformation step to detect and blur unsafe images before they are displayed.
This ensures maximum performance and that sensitive content never flashes on the screen unblurred.
When you load an image with Safe Image, it is first passed through Coil’s request pipeline, which includes a custom transformation. This transformation uses an AI-powered detector to analyze the image before it is displayed. If the detector identifies unsafe content, the image is blurred with a configurable blur radius; otherwise, it is shown normally.
Under the hood, the detection is powered by a TensorFlow Lite model trained to distinguish between safe and unsafe content. Each image is resized, normalized, and classified, and if the probability of sensitive content exceeds a threshold, the image is flagged as NSFW.
To ensure smooth performance, Coil’s memory and disk caching are enabled so images are not repeatedly processed.
Safe Image is built as a Kotlin Multiplatform (KMP) project.
Below are the currently supported targets:
| Platform | Status | Notes |
|---|---|---|
| Android (Compose) | ✅ Implemented | Full support with SafeImage composable |
| Android (XML Views) | ✅ Implemented |
loadSafeImage extension for ImageView |
| iOS | ⏳ Not yet implemented | Planned for future release |
| Desktop | ⏳ Not yet implemented | Planned for future release |
| Web | ⏳ Not yet implemented | Planned for future release |
We are continuously improving Safe Image. Here are some of the planned features and enhancements:
🙌 Contributions and suggestions are always welcome!
Safe Image is proudly developed and maintained by:
Copyright 2025 Team Devura
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License
Safe Image is an AI-powered image filtering library designed to promote safe and culturally appropriate content.
The library uses advanced deep learning models to automatically detect and blur inappropriate or sensitive content in images, with full control over the blur strength, ensuring that visuals remain respectful and aligned with Islamic values.
Make sure Maven Central is added to your project-level build.gradle (or settings.gradle for Gradle 7+):
repositories {
google()
mavenCentral()
}Add Safe Image in module-level build.gradle:
dependencies {
implementation("io.github.devvura:safe-image-compose:1.0.0")
}
If you only want to display an image with automatic blurring, you can use SafelImage with just the model parameter:
SafeImage(
model = "https://example.com/sample.jpg",
contentDescription = "Sample Image"
)You can fully customize SafeImage by providing parameters such as loadingContent, errorContent, onBlurContent, blurRadius, and more:
SafeImage(
modifier = Modifier.fillMaxWidth(),
model = "https://example.com/sample.jpg",
contentDescription = "Sample Image",
loadingContent = { Text(text = "Loading...") },
errorContent = { Text(text = "Error loading image") },
onBlurContent = { Text(text = "Sensitive content")},
blurRadius = 20,
contentScale = ContentScale.FillWidth
)| Parameter | Type | Default | Description |
|---|---|---|---|
model |
Any |
— | The image source (URL, file, resource, etc.) |
contentDescription |
String? |
null |
Description for accessibility (screen readers) |
modifier |
Modifier |
Modifier |
Layout styling (size, padding, etc.) |
loadingContent |
@Composable () -> Unit |
null |
UI to display while the image is loading |
errorContent |
@Composable () -> Unit |
null |
UI to display if loading fails |
onBlurContent |
@Composable () -> Unit |
null |
UI overlay shown when inappropriate content is blurred |
blurRadius |
Int |
16 |
Blur strength applied to blurred images |
contentScale |
ContentScale |
ContentScale.Crop |
Defines how the image should scale inside its container |
Add Safe Image in module-level build.gradle:
dependencies {
implementation("io.github.devvura:safe-image:1.0.0")
}
If you only want to display an image with automatic blurring, you can use SafeImage with just the model parameter:
val imageView = findViewById<ImageView>(R.id.imageView1)
imageView.loadSafeImage(
model = "https://example.com/sample.jpg",
placeholderRes = R.drawable.loading_bar,
errorDrawableRes = R.drawable.error_svgrepo_com
)You can fully customize SafeImage by providing parameters such as onLoading, onError, blurRadius, and more:
val imageView = findViewById<ImageView>(R.id.imageView1)
imageView.loadSafeImage(
model = "https://example.com/sample.jpg",
blurRadius = 70,
onLoading = {
Toast.makeText(context, "Loading image...", Toast.LENGTH_SHORT).show()
},
onError = {
Toast.makeText(context, "Failed to load image", Toast.LENGTH_SHORT).show()
},
onSuccess = {
Toast.makeText(context, "Image loaded successfully!", Toast.LENGTH_SHORT).show()
},
crossFadeEnabled = true,
placeholderRes = R.drawable.loading_bar,
errorDrawableRes = R.drawable.error_svgrepo_com
)| Parameter | Type | Default | Description |
|---|---|---|---|
model |
Any |
— | The image source (URL, file, resource, etc.) |
blurRadius |
Int |
50 |
Blur strength in pixels |
onLoading |
(() -> Unit)? |
null |
Callback triggered when image starts loading |
onError |
(() -> Unit)? |
null |
Callback triggered if image loading fails |
onSuccess |
(() -> Unit)? |
null |
Callback triggered when image loads successfully |
crossFadeEnabled |
Boolean |
true |
Enables smooth crossfade animation between placeholder and image |
placeholderRes |
@DrawableRes Int? |
null |
Drawable resource displayed while loading |
errorDrawableRes |
@DrawableRes Int? |
null |
Drawable resource displayed on error |
Safe Image integrates seamlessly with Coil’s image loading pipeline, working specifically on the Transformation step to detect and blur unsafe images before they are displayed.
This ensures maximum performance and that sensitive content never flashes on the screen unblurred.
When you load an image with Safe Image, it is first passed through Coil’s request pipeline, which includes a custom transformation. This transformation uses an AI-powered detector to analyze the image before it is displayed. If the detector identifies unsafe content, the image is blurred with a configurable blur radius; otherwise, it is shown normally.
Under the hood, the detection is powered by a TensorFlow Lite model trained to distinguish between safe and unsafe content. Each image is resized, normalized, and classified, and if the probability of sensitive content exceeds a threshold, the image is flagged as NSFW.
To ensure smooth performance, Coil’s memory and disk caching are enabled so images are not repeatedly processed.
Safe Image is built as a Kotlin Multiplatform (KMP) project.
Below are the currently supported targets:
| Platform | Status | Notes |
|---|---|---|
| Android (Compose) | ✅ Implemented | Full support with SafeImage composable |
| Android (XML Views) | ✅ Implemented |
loadSafeImage extension for ImageView |
| iOS | ⏳ Not yet implemented | Planned for future release |
| Desktop | ⏳ Not yet implemented | Planned for future release |
| Web | ⏳ Not yet implemented | Planned for future release |
We are continuously improving Safe Image. Here are some of the planned features and enhancements:
🙌 Contributions and suggestions are always welcome!
Safe Image is proudly developed and maintained by:
Copyright 2025 Team Devura
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License