{"id":13601762,"url":"https://github.com/panpf/sketch","last_synced_at":"2025-05-14T01:05:04.011Z","repository":{"id":12194258,"uuid":"14798941","full_name":"panpf/sketch","owner":"panpf","description":"Sketch is an image loading library designed for Compose Multiplatform and Android View. It is powerful and rich in functions. In addition to basic functions, it also supports GIF, SVG, video thumbnails, Exif Orientation, etc.","archived":false,"fork":false,"pushed_at":"2025-04-03T03:16:59.000Z","size":292897,"stargazers_count":2154,"open_issues_count":4,"forks_count":313,"subscribers_count":53,"default_branch":"main","last_synced_at":"2025-04-03T06:48:53.617Z","etag":null,"topics":["android","apk-icon","base64-image","compose","compose-multiplatform","exif","gif","heif","image","image-loader","image-orientation","jetpack-compose","okhttp","svg","video-thumbnail","webp"],"latest_commit_sha":null,"homepage":"https://panpf.github.io/sketch/","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"CSC-IT-Center-for-Science/ansible-role-cuda","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/panpf.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-11-29T10:46:53.000Z","updated_at":"2025-04-03T03:10:18.000Z","dependencies_parsed_at":"2023-02-15T15:01:42.865Z","dependency_job_id":"cc32978b-acbb-441c-aa72-52a1eea9809d","html_url":"https://github.com/panpf/sketch","commit_stats":{"total_commits":3997,"total_committers":6,"mean_commits":666.1666666666666,"dds":0.3845384038028521,"last_synced_commit":"a00f1171d6147835aa614840db680327a52dcc30"},"previous_names":[],"tags_count":113,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panpf%2Fsketch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panpf%2Fsketch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panpf%2Fsketch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panpf%2Fsketch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/panpf","download_url":"https://codeload.github.com/panpf/sketch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248208688,"owners_count":21065205,"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","apk-icon","base64-image","compose","compose-multiplatform","exif","gif","heif","image","image-loader","image-orientation","jetpack-compose","okhttp","svg","video-thumbnail","webp"],"created_at":"2024-08-01T18:01:07.649Z","updated_at":"2025-04-10T11:37:14.192Z","avatar_url":"https://github.com/panpf.png","language":"Kotlin","readme":"# ![logo_image] Sketch Image Loader\n\n![Platform][platform_image]\n[![License][license_image]][license_link]\n[![version_icon]][version_link]\n![QQ Group][qq_group_image]\n\nTranslations: [简体中文](README.zh.md)\n\nSketch is an image loading library specially designed for Compose Multiplatform and Android View. It\nhas the following features:\n\n* `Multiple sources`: Supports loading images from multiple sources such as http, file,\n  compose resource, android asset/content/resource, etc.\n* `Powerful functions`: Supports three-level caching, automatically cancels requests, automatically\n  adjusts image size, automatically rotates images according to Exif Orientation, etc.\n* `Rich functions`: Supports Animated image, SVG images, Base64 images, and video frames\n* `Easy to expand`: Supports expansion of various aspects such as caching, decoding, transformation,\n  transition, placeholder, etc.\n* `Extended functions`: Practical extensions such as pausing downloads when cellular data is\n  provided, pausing loading during list scrolling, image type badges, download progress indicators,\n  etc.\n* `Modern`: Completely based on Kotlin and Kotlin coroutine design\n\n## Sample App\n\n* For Android, iOS, desktop version, and web deployable packages, please go to\n  the [Releases](https://github.com/panpf/sketch/releases) page to download.\n* Web example：https://panpf.github.io/sketch/app\n\n## Install\n\n`Published to mavenCentral`\n\n`${LAST_VERSION}`: [![Download][version_icon]][version_link] (Not included 'v')\n\n### Compose Multiplatform:\n\nImport the required Compose and network modules:\n\n```kotlin\n// Provides the core functions of Sketch as well as singletons and extension \n// functions that rely on singleton implementations\nimplementation(\"io.github.panpf.sketch4:sketch-compose:${LAST_VERSION}\")\n\n// Provides the ability to load network images\nimplementation(\"io.github.panpf.sketch4:sketch-http:${LAST_VERSION}\")\n```\n\n\u003e [!IMPORTANT]\n\u003e To improve the performance of compose, please copy [compose_compiler_config.conf] under\n\u003e the `sketch-core` module file to your project and configure it according to\n\u003e the [Compose Stability Configuration][stability_configuration] documentation\n\n### Android View:\n\nImport the required View and network modules:\n\n```kotlin\n// Provides the core functions of Sketch as well as singletons and extension \n// functions that rely on singleton implementations\nimplementation(\"io.github.panpf.sketch4:sketch-view:${LAST_VERSION}\")\n\n// Provides the ability to load network images\nimplementation(\"io.github.panpf.sketch4:sketch-http:${LAST_VERSION}\")\n```\n\n### Optional modules:\n\n```kotlin\n// Use Android or Skia's built-in decoder to decode gif animations and play them\nimplementation(\"io.github.panpf.sketch4:sketch-animated-gif:${LAST_VERSION}\")\n\n// [Android only] Use the GifDrawable of the android-gif-drawable library to decode and play gif animations\nimplementation(\"io.github.panpf.sketch4:sketch-animated-gif-koral:${LAST_VERSION}\")\n\n// [Android only] Android or Skia's built-in decoder decodes heif animations and plays them\nimplementation(\"io.github.panpf.sketch4:sketch-animated-heif:${LAST_VERSION}\")\n\n// Use Android or Skia's built-in decoder to decode webp animations and play them\nimplementation(\"io.github.panpf.sketch4:sketch-animated-webp:${LAST_VERSION}\")\n\n// Support accessing compose resources through uri or placeholder, fallback, error, etc.\nimplementation(\"io.github.panpf.sketch4:sketch-compose-resources:${LAST_VERSION}\")\nimplementation(\"io.github.panpf.sketch4:sketch-extensions-compose-resources:${LAST_VERSION}\")\n\n// Provides practical functions such as download progress, image type icons, \n//  pausing loading during list scrolling, and saving cellular traffic.\nimplementation(\"io.github.panpf.sketch4:sketch-extensions-compose:${LAST_VERSION}\")\nimplementation(\"io.github.panpf.sketch4:sketch-extensions-view:${LAST_VERSION}\")\n\n// [Android only] Support icon loading of apk files via file path \nimplementation(\"io.github.panpf.sketch4:sketch-extensions-apkicon:${LAST_VERSION}\")\n\n// [Android only] Support loading icons of installed apps by package name and version code\nimplementation(\"io.github.panpf.sketch4:sketch-extensions-appicon:${LAST_VERSION}\")\n\n// [JVM only] Support using HttpURLConnection to access network images\nimplementation(\"io.github.panpf.sketch4:sketch-http-hurl:${LAST_VERSION}\")\n\n// [JVM only] Support using OkHttp to access network images\nimplementation(\"io.github.panpf.sketch4:sketch-http-okhttp:${LAST_VERSION}\")\n\n// Supports using ktor version 2.x to access network images\nimplementation(\"io.github.panpf.sketch4:sketch-http-ktor2:${LAST_VERSION}\")\n\n// Supports using ktor version 3.x to access network images\nimplementation(\"io.github.panpf.sketch4:sketch-http-ktor3:${LAST_VERSION}\")\n\n// Support SVG images\nimplementation(\"io.github.panpf.sketch4:sketch-svg:${LAST_VERSION}\")\n\n// [Android only] Use Android's built-in MediaMetadataRetriever class to decode video frames\nimplementation(\"io.github.panpf.sketch4:sketch-video:${LAST_VERSION}\")\n\n// [Android only] Decoding video frames using wseemann's FFmpegMediaMetadataRetriever library\nimplementation(\"io.github.panpf.sketch4:sketch-video-ffmpeg:${LAST_VERSION}\")\n```\n\n\u003e [!TIP]\n\u003e * `sketch-compose`, `sketch-view` Modules all depend on the singleton provided by\n    the `sketch-singleton` module. If you don’t need the singleton, you can directly rely on\n    their `*-core` version.\n\u003e * The `sketch-http` module depends on `sketch-http-hurl` on jvm platforms and `sketch-http-ktor3`\n    on non-jvm platforms.\n\n### Register component\n\nSketch supports automatic discovery and registration of Fetcher and Decoder components, which are\nimplemented through ServiceLoader on the JVM platform and through the @EagerInitialization\nannotation on non-JVM platforms.\n\nAll built-in modules support automatic registration. If you want to disable automatic registration,\nplease refer to the documentation for manual\nregistration: [《Register component》][register_component]\n\n### R8 / Proguard\n\n1. Android, iOS, Web and other platforms do not need to configure any obfuscation rules\n2. The following obfuscation rules are required for desktop platforms:\n    ```proguard\n    # -------------------------- Sketch Privider ---------------------------- #\n    -keep class * implements com.github.panpf.sketch.util.DecoderProvider { *; }\n    -keep class * implements com.github.panpf.sketch.util.FetcherProvider { *; }\n    ```\n3. It may also be necessary to add obfuscation configurations to the indirect dependencies of\n   three-party libraries such as [Kotlin Coroutines], [OkHttp], [Okio]\n\n## Quickly Started\n\n### Compose Multiplatform:\n\n```kotlin\n// val imageUri = \"/Users/my/Downloads/image.jpg\"\n// val imageUri = file:///compose_resource/composeResources/com.github.panpf.sketch.sample.resources/files/sample.png\nval imageUri = \"https://www.sample.com/image.jpg\"\n\nAsyncImage(\n    uri = imageUri,\n    contentDescription = \"photo\"\n)\n\nAsyncImage(\n    uri = imageUri,\n    state = rememberAsyncImageState(ComposableImageOptions {\n        placeholder(Res.drawable.placeholder)\n        error(Res.drawable.error)\n        crossfade()\n        // There is a lot more...\n    }),\n    contentDescription = \"photo\"\n)\n\nAsyncImage(\n    rqeuest = ComposableImageRequest(imageUri) {\n        placeholder(Res.drawable.placeholder)\n        error(Res.drawable.error)\n        crossfade()\n        // There is a lot more...\n    },\n    contentDescription = \"photo\"\n)\n\nImage(\n    painter = rememberAsyncImagePainter(\n        request = ComposableImageRequest(imageUri) {\n            placeholder(Res.drawable.placeholder)\n            error(Res.drawable.error)\n            crossfade()\n            // There is a lot more...\n        }\n    ),\n    contentDescription = \"photo\"\n)\n```\n\n\u003e [!TIP]\n\u003e `placeholder(Res.drawable.placeholder)` needs to import the `sketch-compose-resources` module\n\n### Android View:\n\n```kotlin\n// val imageUri = \"/sdcard/download/image.jpg\"\n// val imageUri = \"file:///android_asset/image.jpg\"\n// val imageUri = \"content://media/external/images/media/88484\"\nval imageUri = \"https://www.sample.com/image.jpg\"\n\nimageView.loadImage(imageUri)\n\nimageView.loadImage(imageUri) {\n    placeholder(R.drawable.placeholder)\n    error(R.drawable.error)\n    crossfade()\n    // There is a lot more...\n}\n\nval request = ImageRequest(context, imageUri) {\n    placeholder(R.drawable.placeholder)\n    error(R.drawable.error)\n    crossfade()\n    target(imageView)\n    // There is a lot more...\n}\ncontext.sketch.enqueue(request)\n```\n\n## Documents\n\nBasic functions:\n\n* [Get Started][getting_started]\n* [Register component][register_component]\n* [Compose][compose]\n* [Http: Load network images][http]\n* [AnimatedImage: GIF、WEBP、HEIF][animated_image]\n* [Resize: Modify the image size][resize]\n* [Transformation: Transformation image][transformation]\n* [Transition: Display images in cool transitions][transition]\n* [StateImage: Placeholder and error images][state_image]\n* [Listener: Listen for request status and download progress][listener]\n* [DownloadCache: Understand download caching to avoid repeated downloads][download_cache]\n* [ResultCache: Understand result caching to avoid duplicate conversions][result_cache]\n* [MemoryCache: Understand memory caching to avoid repeated loading][memory_cache]\n* [Fetcher: Learn about Fetcher and extend new URI types][fetcher]\n* [Decoder: Understand the decoding process of Sketch][decoder]\n* [Target: Apply the load results to the target][target]\n* [SVG: Decode SVG still images][svg]\n* [VideoFrames: Decode video frames][video_frame]\n* [ExifOrientation: Correct the image orientation][exif_orientation]\n* [ImageOptions: Manage image configurations in a unified manner][image_options]\n* [RequestInterceptor: Intercept ImageRequest][request_interceptor]\n* [DecodeInterceptor: Intercept the decoding process][decode_interceptor]\n* [Preload images into memory][preload]\n* [Download images][download]\n* [Lifecycle][lifecycle]\n* [Log][log]\n* [Migrate][migrate]\n\nFeatured functions:\n\n* [SketchImageView: Configure the request through XML attributes][sketch_image_view]\n* [Improve the clarity of long images in grid lists][long_image_grid_thumbnails]\n* [Displays the download progress][progress_indicator]\n* [Displays the image type corner][mime_type_logo]\n* [Pause image downloads on cellular data to save data][save_cellular_traffic]\n* [The list slides to pause the loading of images][pause_load_when_scrolling]\n* [Displays an icon for an apk file or installed app][apk_app_icon]\n\n## Change log\n\nPlease review the [CHANGELOG.md] file\n\n## Test Platform\n\n* Android: Emulator; Arm64; API 21-34\n* Desktop: macOS; 14.6.1; JDK 17\n* iOS: iphone 16 simulator; iOS 18.1\n* Web: Chrome; 130\n\n## Run Sample App\n\nPrepare the environment:\n\n1. Android Studio: Koala+ (2024.1.1+)\n2. JDK: 17+\n3. Use [kdoctor] to check the running environment and follow the prompts to install the required\n   software\n4. Android Studio installs the `Kotlin Multiplatform` and `Compose Multiplatform IDE Support`plugins\n\nRun the sample app:\n\n1. Clone the project and open it using Android Studio\n2. The running configurations of each platform have been added to the `.run` directory. After\n   synchronization is completed, directly select the running configuration of the corresponding\n   platform in the running configuration drop-down box at the top of Android Studio and click Run.\n3. The running configuration of the ios platform requires you to manually create it according to the\n   template, as follows:\n    1. Copy the `.run/iosSample.run.template.xml` file and remove the `.template` suffix.\n       The `.ignore` file has been configured to ignore `iosSample.run.xml`\n    2. Click `Edit Configurations` in the run configuration drop-down box at the top,\n       select `iosSample` and then configure `Execute target`\n\n## About version 4.0\n\n* The maven groupId is upgraded to `io.github.panpf.sketch4`, so versions 2.\\* and 3.\\* will not\n  prompt for upgrade\n* Version 4.0 is specially built for Compose Multiplatform, so there are many breaking changes in\n  the API, please upgrade with caution\n* Version 4.0 has made a lot of simplifications and is much simpler than version 3.0, please check\n  the update log for details\n* Android minimum API raised to API 21\n* Kotlin version upgraded to 2.0.0\n\n## Special thanks\n\n* [coil-kt/coil][coil]: Sketch uses some code from Coil, including framework, compose and\n  sketch-animated movie part\n* [koral--/android-gif-drawable][android-gif-drawable]: animated-koralgif\n* [wseemann/FFmpegMediaMetadataRetriever][FFmpegMediaMetadataRetriever]: video-ffmpeg\n* [BigBadaboom/androidsvg][androidsvg]: svg\n\n## My Projects\n\nThe following are my other open source projects. If you are interested, you can learn about them:\n\n* [zoomimage](https://github.com/panpf/zoomimage): Library for zoom images, supported Android View,\n  Compose and Compose Multiplatform; supported double-click zoom, One or two fingers gesture zoom,\n  single-finger drag, inertial sliding, positioning, rotation, super-large image subsampling and\n  other functions.\n* [assembly-adapter](https://github.com/panpf/assembly-adapter): A library on Android that provides\n  multi-type Item implementations for various adapters. Incidentally, it also provides the most\n  powerful divider for RecyclerView.\n* [sticky-item-decoration](https://github.com/panpf/stickyitemdecoration): RecyclerView sticky item\n  implementation\n\n## License\n\nApache 2.0. See the [LICENSE](LICENSE.txt) file for details.\n\n[comment]: \u003c\u003e (header)\n\n[license_image]: https://img.shields.io/badge/License-Apache%202-blue.svg\n\n[logo_image]: docs/images/logo.png\n\n[license_link]: https://www.apache.org/licenses/LICENSE-2.0\n\n[platform_image]: https://img.shields.io/badge/Platform-ComposeMultiplatform-brightgreen.svg\n\n[qq_group_image]: https://img.shields.io/badge/QQ%E4%BA%A4%E6%B5%81%E7%BE%A4-529630740-red.svg\n\n[version_icon]: https://img.shields.io/maven-central/v/io.github.panpf.sketch4/sketch-singleton\n\n[version_link]: https://repo1.maven.org/maven2/io/github/panpf/sketch4/\n\n\n[comment]: \u003c\u003e (wiki)\n\n[animated_image]: docs/animated_image.md\n\n[apk_app_icon]: docs/apk_app_icon.md\n\n[compose]: docs/compose.md\n\n[decoder]: docs/decoder.md\n\n[download_cache]: docs/download_cache.md\n\n[exif_orientation]: docs/exif_orientation.md\n\n[fetcher]: docs/fetcher.md\n\n[getting_started]: docs/getting_started.md\n\n[register_component]: docs/register_component.md\n\n[http]: docs/http.md\n\n[image_options]: docs/image_options.md\n\n[lifecycle]: docs/lifecycle.md\n\n[listener]: docs/listener.md\n\n[log]: docs/log.md\n\n[long_image_grid_thumbnails]: docs/long_image_grid_thumbnails.md\n\n[memory_cache]: docs/memory_cache.md\n\n[mime_type_logo]: docs/mime_type_logo.md\n\n[pause_load_when_scrolling]: docs/pause_load_when_scrolling.md\n\n[preload]: docs/preload.md\n\n[download]: docs/download_image.md\n\n[progress_indicator]: docs/progress_indicator.md\n\n[request_interceptor]: docs/request_interceptor.md\n\n[decode_interceptor]: docs/decode_interceptor.md\n\n[resize]: docs/resize.md\n\n[result_cache]: docs/result_cache.md\n\n[save_cellular_traffic]: docs/save_cellular_traffic.md\n\n[sketch_image_view]: docs/sketch_image_view.md\n\n[state_image]: docs/state_image.md\n\n[svg]: docs/svg.md\n\n[target]: docs/target.md\n\n[transformation]: docs/transformation.md\n\n[transition]: docs/transition.md\n\n[video_frame]: docs/video_frame.md\n\n[migrate]: docs/migrate.md\n\n\n[comment]: \u003c\u003e (links)\n\n\n[androidsvg]: https://github.com/BigBadaboom/androidsvg\n\n[android-gif-drawable]: https://github.com/koral--/android-gif-drawable\n\n[coil]: https://github.com/coil-kt/coil\n\n[FFmpegMediaMetadataRetriever]: https://github.com/wseemann/FFmpegMediaMetadataRetriever\n\n\n[Kotlin Coroutines]: https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro\n\n[OkHttp]: https://square.github.io/okhttp/features/r8_proguard/\n\n[Okio]: https://square.github.io/okio/\n\n\n[compose_compiler_config.conf]: sketch-core/compose_compiler_config.conf\n\n[stability_configuration]: https://developer.android.com/develop/ui/compose/performance/stability/fix#configuration-file\n\n\n[comment]: \u003c\u003e (footer)\n\n[CHANGELOG.md]: CHANGELOG.md\n\n[kdoctor]: https://github.com/Kotlin/kdoctor\n","funding_links":[],"categories":["Multiplatform","Libraries","android"],"sub_categories":["Android samples","🍎 Compose UI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanpf%2Fsketch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpanpf%2Fsketch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanpf%2Fsketch/lists"}