Sketch is a powerful and comprehensive image load library on Android, in addition to the basic functions, it also supports Jetpack Compose, GIF, SVG, video thumbnails, gesture zoom, huge images sampling, ExifInterface and other functions. Sketch 是 Android 上的一个强大且全面的图片加载库,除了基础功能外,还支持 Jetpack Compose、GIF、SVG、视频缩略图、手势缩放、超大图采样、ExifInterface 等功能。
Translations: 简体中文
Sketch is a powerful and comprehensive image load library on Android, in addition to the basic functions, it also supports Jetpack Compose, GIF, SVG, video thumbnails, gesture zoom, huge images sampling, ExifInterface and other functions.
Published to mavenCentral
dependencies {
// The core functionality of Sketch is provided as well as a singleton and some
// handy extension functions that depend on this singleton implementation,
// and if you don't need a singleton, you can use the sketch-core module
implementation("io.github.panpf.sketch3:sketch:${LAST_VERSION}")
}
${LAST_VERSION}
: (Not included 'v')
There are also optional modules to extend the functionality of sketch:
dependencies {
// Support for Jetpack Compose.
// It relies on the singletons provided by the sketch module,
// and you can use the sketch-compose-core module if you don't need the singleton pattern
implementation("io.github.panpf.sketch3:sketch-compose:${LAST_VERSION}")
// Provides View with practical functions such as download progress,
// pausing loading during list sliding, saving cellular data,
// image type corner icons, loading apk files and installed app icons, etc.
// It relies on the singleton provided by the sketch module.
// If you do not need the singleton mode, you can use the sketch-view-core module.
implementation("io.github.panpf.sketch3:sketch-extensions-view:${LAST_VERSION}")
// Provide Compose with practical functions such as download progress,
// pausing loading during list sliding, saving cellular data,
// image type corner icons, loading apk files and installed app icons, etc.
implementation("io.github.panpf.sketch3:sketch-extensions-compose:${LAST_VERSION}")
// GIF playback is achieved through Android's built-in ImageDecoder and Movie class
implementation("io.github.panpf.sketch3:sketch-gif:${LAST_VERSION}")
// GifDrawable through Koral's android-gif-drawable library
implementation("io.github.panpf.sketch3:sketch-gif-koral:${LAST_VERSION}")
// Support for OkHttp
implementation("io.github.panpf.sketch3:sketch-okhttp:${LAST_VERSION}")
// SVG images are supported
implementation("io.github.panpf.sketch3:sketch-svg:${LAST_VERSION}")
// Video frames are read through Android's built-in MediaMetadataRetriever class
implementation("io.github.panpf.sketch3:sketch-video:${LAST_VERSION}")
// Video frames are read through wseemann's FFmpegMediaMetadataRetriever library
implementation("io.github.panpf.sketch3:sketch-video-ffmpeg:${LAST_VERSION}")
// Supports gesture zoom and jumbo sampling
implementation("io.github.panpf.sketch3:sketch-zoom:${LAST_VERSION}")
}
Sketch doesn't need to configure any obfuscation rules itself, but you may need to add obfuscation configurations for indirectly dependent Kotlin Coroutines, OkHttp, Okio.
Sketch provides a series of extended functions called displayImage for ImageView, which can easily display images
// http
imageView.displayImage("https://www.sample.com/image.jpg")
// File
imageView.displayImage("/sdcard/download/image.jpg")
// asset
imageView.displayImage("asset://image.jpg")
// There is a lot more...
You can also configure parameters through a trailing lambda function:
imageView.displayImage("https://www.sample.com/image.jpg") {
placeholder(R.drawable.placeholder)
error(R.drawable.error)
transformations(CircleCropTransformation())
crossfade()
// There is a lot more...
}
[!IMPORTANT] Required import
sketch-compose
module
AsyncImage(
imageUri = "https://www.sample.com/image.jpg",
modifier = Modifier.size(300.dp, 200.dp),
contentScale = ContentScale.Crop,
contentDescription = ""
)
// config params
AsyncImage(
rqeuest = DisplayRequest(LocalContext.current, "https://www.sample.com/image.jpg") {
placeholder(R.drawable.placeholder)
error(R.drawable.error)
transformations(BlurTransformation())
crossfade()
// There is a lot more...
},
modifier = Modifier.size(300.dp, 200.dp),
contentScale = ContentScale.Crop,
contentDescription = ""
)
Basic functions:
Featured functions:
Please review the CHANGELOG.md file
The following are my other open source projects. If you are interested, you can learn about them:
Apache 2.0. See the LICENSE file for details.