Tanexc / ImageTool

🖼️ Kotlin Multiplatform library for loading, caching images
Apache License 2.0
2 stars 1 forks source link
action compose compose-multiplatform kmp koin kotlin kotlin-multiplatform ktor library maven maven-repository workflow

🖼️ ImageTool

ImageTool is a Kotlin multiplatform library that provides the ability to download and cache images from network, storage and etc. Now library available on Android and IOS platforms

Implementation

GitHub Release

For Kotlin DSL :

  implementation("io.github.tanexc:imagetool:[version]")

For Groovy DSL :

  implementation "io.github.tanexc:imagetool:[version]"

For libs.version.toml :

Add implementation(libs.imagetool) to build.gradle.kts and


  [versions]

  imagetool-version="version"

  #...

  [libraries]

  #...

  imagetool = { module = "io.github.tanexc:imagetool", version.ref = "imagetool-version" }

Usage

At this moment available just one widget to use:

  @Composable
  fun ComposeImage(
    model: String,                    
    contentDescription: String?,                             
    modifier: Modifier = Modifier,                           
    alignment: Alignment = Alignment.Center,                   
    contentScale: ContentScale = ContentScale.Fit,
    alpha: Float = DefaultAlpha,
    colorFilter: ColorFilter? = null,
    filterQuality: FilterQuality = DefaultFilterQuality,
    cacheQuality: CacheQuality = CacheQuality.NoCompressing,
    onLoading: @Composable BoxScope.(progress: Float) -> Unit,
    onError: @Composable BoxScope.() -> Unit,
)

model - Url string of the image

contentDescription - Description of the image

modififer - Modifier used to adjust the layout algorithm or draw decoration content (ex. background)

alignment - Optional alignment parameter used to place the ImageBitmap in the given bounds defined by the width and height

contentScale - Optional scale parameter used to determine the aspect ratio scaling to be used if the bounds are a different size from the intrinsic size of the ImageBitmap

alpha - Optional opacity to be applied to the ImageBitmap when it is rendered onscreen

colorFilter - Optional ColorFilter to apply for the ImageBitmap when it is rendered

filterQuality - Sampling algorithm applied to the bitmap when it is scaled and drawn into the destination. The default is FilterQuality. Low which scales using a bilinear sampling algorithm

cacheQuality - CacheQuality used to set quality of cached image

onLoading - Composable that will be displayed on loading. Receives float progress from 0.0 to 1.0

onError - Composable that will be displayed when loading failed

In future

Tech stack

Have suggestions or questions?

Contact me here:

Find this repository useful? :heart:

Support it by joining stargazers for this repository. :star:
And follow me!

License

Designed and developed by 2024 Tanexc

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.