{"id":29278013,"url":"https://github.com/ltttttttttttt/load-the-image","last_synced_at":"2025-07-05T10:04:14.420Z","repository":{"id":44423653,"uuid":"478460128","full_name":"ltttttttttttt/load-the-image","owner":"ltttttttttttt","description":"桌面端图片加载框架, load-the-image Apply to compose-jb(desktop), Used to load network and local pictures,  supports caching.","archived":false,"fork":false,"pushed_at":"2024-04-23T03:07:46.000Z","size":715,"stargazers_count":32,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-23T06:23:07.433Z","etag":null,"topics":["compose","compose-jb","desktop","desktopimageloader","imageloader","kmm","kmp","kotlin","kotlin-library","loadimagefromurl"],"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/ltttttttttttt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2022-04-06T07:58:20.000Z","updated_at":"2024-04-23T03:06:32.000Z","dependencies_parsed_at":"2024-04-23T04:39:00.708Z","dependency_job_id":"4992e500-ee04-4bdd-9d60-f141c5eaf792","html_url":"https://github.com/ltttttttttttt/load-the-image","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/ltttttttttttt/load-the-image","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltttttttttttt%2Fload-the-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltttttttttttt%2Fload-the-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltttttttttttt%2Fload-the-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltttttttttttt%2Fload-the-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ltttttttttttt","download_url":"https://codeload.github.com/ltttttttttttt/load-the-image/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltttttttttttt%2Fload-the-image/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263723227,"owners_count":23501500,"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":["compose","compose-jb","desktop","desktopimageloader","imageloader","kmm","kmp","kotlin","kotlin-library","loadimagefromurl"],"created_at":"2025-07-05T10:04:13.578Z","updated_at":"2025-07-05T10:04:14.415Z","avatar_url":"https://github.com/ltttttttttttt.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[简体中文](https://blog.csdn.net/qq_33505109/article/details/125194044)\n\n# load-the-image\n\nload-the-image Apply to compose-jb(desktop), Used to load network and local pictures.\n\nExample:\n\n![Example](md_resource/example.png)\n\n\u003ch1\u003eMode of use\u003c/h1\u003e\n\nUse the code load image with network, file, resources and more\n\n```kotlin\n//url=\"https://img.zcool.cn/community/017e625e57415ea801216518c25819.jpg@1280w_1l_2o_100sh.jpg\"\nImage(rememberImagePainter(url), \"\")\n```\n\n\u003ch3\u003eAdd to your project\u003c/h3\u003e\n\nStep 1.Root dir, build.gradle.kts add:\n\n```kotlin\nbuildscript {\n    repositories {\n        maven(\"https://jitpack.io\")//this\n        ...\n    }\n}\n\nallprojects {\n    repositories {\n        maven(\"https://jitpack.io\")//this\n        ...\n    }\n}\n```\n\nStep 2.Your compose-desktop dir, build.gradle.kts add:\n\nversion = [![](https://jitpack.io/v/ltttttttttttt/load-the-image.svg)](https://jitpack.io/#ltttttttttttt/load-the-image)\n\n```kotlin\nkotlin {\n    sourceSets {\n        val jvmMain by getting {\n            dependencies {\n                ...\n                implementation(\"com.github.ltttttttttttt:load-the-image:$version\")//this\n            }\n        }\n    }\n}\n```\n\nStep 3.Recommendation: uniformly configure the failure graph path displayed when loading fails\n\n```kotlin\nfun main() {\n    LoadTheImageManager.defaultErrorImagePath = \"drawable-xxhdpi/load_error.jpeg\"//this\n    application {\n        Window(onCloseRequest = ::exitApplication) {\n            MaterialTheme {\n                Image(rememberImagePainter(\"https://img.zcool.cn/community/017e625e57415ea801216518c25819.jpg@1280w_1l_2o_100sh.jpg\"),\"\")\n            }\n        }\n    }\n}\n```\n\nps:Reference of Resource location, you can customize\n\n![Resource location](md_resource/resource_location.png)\n\nStep 4.Recommendation:  set the version of Compose-jb(desktop) to 1.1.1 or above\n\nAccording to the feedback, it is found that there is a bug in the 1.1.0 version of compose JB, which will not start\n\n\u003ch1\u003eCustom configuration\u003c/h1\u003e\n\n\u003ch3\u003e1.Configure placeholder and error image\u003c/h3\u003e\n\nYou can use the default parameters in the method\n\n![placeholder](md_resource/use_placeholder.png)\n\nUsage:\n\n```kotlin\nrememberImagePainter(url, /*the placeholder path*/)\n```\n\nOr:\n\n```kotlin\n    rememberImagePainter(DataToBeLoaded(url).apply {\n        placeholderResource = /*the placeholder path*/\n        errorImagePath = /*the error resource path*/\n    })\n```\n\n\u003ch3\u003e2.Modify memory cache size\u003c/h3\u003e\n\n```kotlin\nLoadTheImageManager.memoryCache = ImageLruMemoryCache(/*max memory cache size*/)\n```\n\nps:Default memory cache size:maxOf(50MB, 1% of total memory)\n\nYou can customize:\n\n```kotlin\nLoadTheImageManager.memoryCache = /*your class*/\n```\n\n\u003ch3\u003e3.Modify file cache location\u003c/h3\u003e\n\n```kotlin\nLoadTheImageManager.fileCache = ImageFileCache(File(\"C://test_dir\"))\n```\n\nOr:\n\n```kotlin\nLoadTheImageManager.fileCache = /*your class*/\n```\n\nps:Default file cache location: user\\Pictures\\LoadTheImageCache\n\n\u003ch3\u003e4.Modify http loader\u003c/h3\u003e\n\n```kotlin\nLoadTheImageManager.httpLoader = /*your class*/\n```\n\n\u003ch3\u003e5.Load-the-image supports multiple formats, And it can be expanded by itself\u003c/h3\u003e\n\n![function formats](md_resource/formats.png)\n\nCustom reference below:\n\nOne.Implement your class:\n\n![custom_load-the-image](md_resource/custom_LoadTheImage.png)\n\nTwo.Configure:\n```kotlin\nLoadTheImageManager.loadTheImage.add(ByteArrayLoadTheImage()/*your class*/)\n```\n\nThree.Use:\n```kotlin\nrememberImagePainter(DataToBeLoaded(byteArrayOf()))//Better seal it\n```\n\n\u003ch1\u003eIf you use compose(Kotlin Multiplatform), You can refer to the example.\u003c/h1\u003e\n\nversion = [![](https://jitpack.io/v/ltttttttttttt/load-the-image.svg)](https://jitpack.io/#ltttttttttttt/load-the-image)\n\nYour common dir, build.gradle.kts add:\n\n```kotlin\nval desktopMain by getting{\n\tdependencies {\n\t\timplementation 'com.github.ltttttttttttt:load-the-image:$version'\n\t}\n}\n```\n\ncommonMain add function:\n\n```kotlin\n@Composable\nexpect fun rememberImagePainter(url: String): Painter\n```\n\nandroidMain add function(and other target):\n\n```kotlin\n@Composable\nactual fun rememberImagePainter(url: String): Painter =\n    coil.compose.rememberImagePainter(data = url)\n```\n\ndesktopMain add function:\n\n```kotlin\n@Composable\nactual fun rememberImagePainter(url: String): Painter =\n    com.lt.load_the_image.rememberImagePainter(url)\n    \n```\nUse the code load image with network and file and resources\n\n```kotlin\nImage(rememberImagePainter(/*url*/\"https://img.zcool.cn/community/017e625e57415ea801216518c25819.jpg@1280w_1l_2o_100sh.jpg\",\"\")\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltttttttttttt%2Fload-the-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fltttttttttttt%2Fload-the-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltttttttttttt%2Fload-the-image/lists"}