{"id":15527910,"url":"https://github.com/fummicc1/asyncdownsamplingimage","last_synced_at":"2025-04-23T12:31:04.233Z","repository":{"id":65696296,"uuid":"595241545","full_name":"fummicc1/AsyncDownSamplingImage","owner":"fummicc1","description":"Extended AsyncImage to perform down sampling when downloading image","archived":false,"fork":false,"pushed_at":"2025-02-02T02:27:26.000Z","size":3091,"stargazers_count":18,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T02:47:51.008Z","etag":null,"topics":["asyncimage","downsampling","public","swiftui"],"latest_commit_sha":null,"homepage":"https://medium.com/@fummicc1/asyncimage-that-can-perform-downsampling-947c11da66d1","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fummicc1.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,"publiccode":null,"codemeta":null}},"created_at":"2023-01-30T17:28:10.000Z","updated_at":"2025-02-02T13:37:01.000Z","dependencies_parsed_at":"2024-07-06T01:57:26.422Z","dependency_job_id":"87244881-fe98-444e-80d7-a32d72c191e8","html_url":"https://github.com/fummicc1/AsyncDownSamplingImage","commit_stats":{"total_commits":18,"total_committers":2,"mean_commits":9.0,"dds":"0.38888888888888884","last_synced_commit":"27dab11e659b26eb6cf0323937c32f2580d156ab"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fummicc1%2FAsyncDownSamplingImage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fummicc1%2FAsyncDownSamplingImage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fummicc1%2FAsyncDownSamplingImage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fummicc1%2FAsyncDownSamplingImage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fummicc1","download_url":"https://codeload.github.com/fummicc1/AsyncDownSamplingImage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250434614,"owners_count":21430136,"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":["asyncimage","downsampling","public","swiftui"],"created_at":"2024-10-02T11:09:51.162Z","updated_at":"2025-04-23T12:31:04.213Z","avatar_url":"https://github.com/fummicc1.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AsyncDownSamplingImage\n\n`AsyncDownSamplingImage` is a SwiftUI component that has similar interface to original [AsyncImage](https://developer.apple.com/documentation/swiftui/asyncimage) and can perform downsampling so that we can reduce the memory buffer to store image data fetched from a server.\n\n\u003cimg src=\"https://github.com/fummicc1/AsyncDownSamplingImage/assets/44002126/254ee84d-1e08-4a61-b507-8f78f2e1d6d3\" width=\"320px\"\u003e\n\n## Impact of Downsampling\n\nwith downsampling, we can reduce the huge amount of memory use like the below.\n\n|default AsyncImage| AsyncDownSamplingImage (×2~3 efficient) |\n|---|---|\n|\u003cimg width=\"480\" alt=\"Screenshot 2023-02-03 at 21 58 31\" src=\"https://user-images.githubusercontent.com/44002126/216665559-7f4efbc5-c649-4f25-b9fa-95f5ca60cf67.png\"\u003e|\u003cimg width=\"480\" alt=\"Screenshot 2023-02-03 at 21 58 48\" src=\"https://user-images.githubusercontent.com/44002126/216665576-f1b994a7-b7ac-49d3-8e44-bda8f1b64130.png\"\u003e|\n\n\nMoreover, the more the number of images increases, the more we can get the benefit.\n\nBelow is a comparision when I scrolled and show 100/1000 high resolution images (1000×1000px).\nWith AsyncDownSamplingImage, we changed Image size `1000x1000` into `160x160` which is same size as rendered `Image`.\n\n|100 Default AsyncImages| 100 AsyncDownSamplingImages (×10~ efficient) |\n|---|---|\n|\u003cimg width=\"480\" alt=\"Screenshot 2023-02-04 at 2 11 31\" src=\"https://user-images.githubusercontent.com/44002126/216666328-6d4ea99c-45d4-48d0-960d-b162a9155413.png\"\u003e|\u003cimg width=\"480\" alt=\"Screenshot 2023-02-04 at 2 12 06\" src=\"https://user-images.githubusercontent.com/44002126/216666337-0e079274-5a55-4469-b9ae-4c4dfc5b838d.png\"\u003e|\n\n|1000 Default AsyncImages| 1000 AsyncDownSamplingImages (×30~ efficient) |\n|---|---|\n|\u003cimg width=\"480\" alt=\"Screenshot 2023-02-06 at 1 08 46\" src=\"https://user-images.githubusercontent.com/44002126/216831204-06a8dc04-6bd6-44df-8134-290f150abca0.png\"\u003e|\u003cimg width=\"480\" alt=\"Screenshot 2023-02-06 at 1 07 29\" src=\"https://user-images.githubusercontent.com/44002126/216831199-c5a66b8e-fc1a-4131-a5c5-2f7d57b17a1b.png\"\u003e|\n\n## Installation\n\n```swift\n.package(url: \"https://github.com/fummicc1/AsyncDownSamplingImage.git\", from: \"1.1.0\")\n```\n\n## How to use AsyncDownSamplingImage\n\n`AsyncDownSamplingImage` aims to be used in a similar way to `AsyncImage` even if the implementation is different.\n\n```swift\npublic init(\n  url: Binding\u003cURL?\u003e,\n  downsampleSize: Binding\u003cCGSize\u003e,\n  content: @escaping (Image) -\u003e Content,\n  placeholder: @escaping () -\u003e Placeholder,\n  fail: @escaping (Error) -\u003e Fail\n)\n```\n\n```swift\npublic init(\n  url: URL?,\n  downsampleSize: Binding\u003cCGSize\u003e,\n  content: @escaping (Image) -\u003e Content,\n  fail: @escaping (Error) -\u003e Fail\n)\n```\n\n```swift\npublic init(\n  url: URL?,\n  downsampleSize: CGSize,\n  content: @escaping (Image) -\u003e Content,\n  fail: @escaping (Error) -\u003e Fail\n)\n```\n\nYou can use `AsyncDownSamplingImage` in the following way.\n\n```swift\n\n@State private var url = URL(string: \"https://via.placeholder.com/1000\")\n@State private var size: CGSize = .init(width: 160, height: 160)\n\n...\n\nAsyncDownSamplingImage(\n  url: url,\n  downsampleSize: size\n) { image in\n  image.resizable()\n      .frame(width: size.width, height: size.height)\n} fail: { error in\n  Text(\"Error: \\(error.localizedDescription)\")\n}\n```\n\n## How to use IncrementalImage\n\nIncrementalImage is a component that can load image data in chunks.\nThe size of buffer is set by `bufferSize` parameter in bytes unit.\n\n```swift\nlet url = URL(string: \"https://via.placeholder.com/1000\")\n\nIncrementalImage(url: url, bufferSize: 1 * 1024)\n```\n\n## DocC\n\n[Documentation](https://fummicc1.github.io/AsyncDownSamplingImage/documentation/asyncdownsamplingimage/) generated by DocC is available (still working in progress).\n\n## Contributing\n\nPull requests, bug reports and feature requests are welcome 🚀\n\n## License\n\n[MIT LICENSE](https://github.com/fummicc1/AsyncDownSamplingImage/blob/main/LICENSE)\n\n## Reference\n\n- https://medium.com/@zippicoder/downsampling-images-for-better-memory-consumption-and-uicollectionview-performance-35e0b4526425\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffummicc1%2Fasyncdownsamplingimage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffummicc1%2Fasyncdownsamplingimage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffummicc1%2Fasyncdownsamplingimage/lists"}