DefaultTransform
+ A state transform that does not modify the state.
diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000000..e69de29bb2 diff --git a/404.html b/404.html new file mode 100644 index 0000000000..db2d1e9bd8 --- /dev/null +++ b/404.html @@ -0,0 +1 @@ +
Coil は Kotlin Coroutines で作られた Android 用の画像読み込みライブラリです。 Coil は:
Coil は Coroutine Image Loader の頭字語です。
Coil は mavenCentral()
で利用できます。
画像を ImageView
に読み込むには、 load
拡張関数を使用します。
// URL
+imageView.load("https://example.com/image.jpg")
+
+// File
+imageView.load(File("/path/to/image.jpg"))
+
+// And more...
+
Requests は、 trailing lambda 式を使用して追加の設定を行うことができます:
imageView.load("https://example.com/image.jpg") {
+ crossfade(true)
+ placeholder(R.drawable.image)
+ transformations(CircleCropTransformation())
+}
+
Jetpack Compose 拡張ライブラリをインポートします:
画像を読み込むには、AsyncImage
composable を使用します:
imageView.load
と AsyncImage
はシングルトンの ImageLoader
を使用して画像リクエストを実行します。 シングルトンの ImageLoader
には Context
拡張関数を使用してアクセスできます:
ImageLoader
は共有できるように設計されており、単一のインスタンスを作成してアプリ全体で共有すると最も効率的です。 また、独自の ImageLoader
インスタンスを作成することもできます:
シングルトンの ImageLoader
が必要ない場合は、 io.coil-kt:coil
の代わりに io.coil-kt:coil-base
を使用してください。
画像をカスタムターゲットにロードするには、 ImageRequest
を enqueue
してください:
val request = ImageRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .target { drawable ->
+ // Handle the result.
+ }
+ .build()
+val disposable = imageLoader.enqueue(request)
+
画像を命令的にロードするには、 ImageRequest
を execute
してください:
val request = ImageRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .build()
+val drawable = imageLoader.execute(request).drawable
+
こちらで Coil の完全なドキュメント を確認してください。
Coil は R8 と完全に互換性があり、追加のルールを追加する必要はありません。
Proguardを使用している場合は、Coroutines、OkHttpにルールを追加する必要があるかもしれません。
Copyright 2024 Coil Contributors
+
+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
+
+ https://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.
+
Coil은 Kotlin Coroutines으로 만들어진 Android 백앤드 이미지 로딩 라이브러리입니다. Coil 은:
Coil은: Coroutine Image Loader의 약자입니다.
Coil은 mavenCentral()
로 이용 가능합니다.
ImageView
로 이미지를 불러오기 위해, load
확장 함수를 사용합니다.
// URL
+imageView.load("https://example.com/image.jpg")
+
+// File
+imageView.load(File("/path/to/image.jpg"))
+
+// And more...
+
Requests는 trailing lambda 식을 이용하여 추가 설정을 할 수 있습니다:
imageView.load("https://example.com/image.jpg") {
+ crossfade(true)
+ placeholder(R.drawable.image)
+ transformations(CircleCropTransformation())
+}
+
Jetpack Compose 확장 라이브러리 추가:
이미지를 불러오려면, AsyncImage
composable를 사용하세요:
imageView.load
와 AsyncImage
는 이미지를 불러오기 위해 싱글톤 ImageLoader
를 사용합니다. 싱글톤 ImageLoader
는 Context
의 확장함수를 통해 접근할 수 있습니다:
ImageLoader
는 공유가 가능하게 설계 되었으며, 싱글 객체를 만들어서 앱에 전반적으로 사용했을 때 가장 효율적입니다. 즉, 직접 ImageLoader
인스턴스를 생성해도 됩니다:
싱글톤 ImageLoader
를 사용하고 싶지 않을때에는, io.coil-kt:coil
를 참조하는 대신, io.coil-kt:coil-base
를 참조하세요.
커스텀 타겟에 이미지를 로드하려면, ImageRequest
를 enqueue
하세요:
val request = ImageRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .target { drawable ->
+ // Handle the result.
+ }
+ .build()
+val disposable = imageLoader.enqueue(request)
+
Imperative하게 이미지 로드를 하려면, ImageRequest
를 execute
하세요:
val request = ImageRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .build()
+val drawable = imageLoader.execute(request).drawable
+
여기서 Coil의 전체 문서를 확인하세요.
Coil은 별도의 설정 없이 R8과 완벽하게 호환 가능하며 추가 규칙이 필요하지 않습니다.
Proguard를 사용할 경우, Coroutines와 OkHttp의 규칙을 추가할 필요가 있을 수 있습니다.
Copyright 2024 Coil Contributors
+
+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
+
+ https://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.
+
Библиотека для загрузки изображений на Android, работающая с корутинами Kotlin. Coil - это:
Coil - аббревиатура: Coroutine Image Loader (загрузчик изображений при помощи корутин).
Coil доступен в mavenCentral()
.
Чтобы загрузить изображение в ImageView
, воспользуйтесь расширением load
:
// URL
+imageView.load("https://example.com/image.jpg")
+
+// Файл
+imageView.load(File("/path/to/image.jpg"))
+
+// И многое другое...
+
Запросы могут конфигурироваться лямбда-функцией:
imageView.load("https://example.com/image.jpg") {
+ crossfade(true)
+ placeholder(R.drawable.image)
+ transformations(CircleCropTransformation())
+}
+
Установите библиотеку-расширение для Jetpack Compose:
Чтобы загрузить изображение, воспользуйтесь composable-функцией AsyncImage
:
Как imageView.load
, так и AsyncImage
используют синглтон ImageLoader
для исполнения запросов на загрузку. Синглтон ImageLoader
доступен через расширение Context
:
ImageLoader
ы максимально эффективны, когда во всем приложении используется один и тот же его экземпляр. Тем не менее, вы можете создавать и свои экземпляры ImageLoader
, если потребуется:
Если вам не требуется синглтон ImageLoader
, используйте io.coil-kt:coil-base
вместо io.coil-kt:coil
.
Чтобы загрузить изображение в заданную цель, выполните метод enqueue
на ImageRequest
:
val request = ImageRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .target { drawable ->
+ // Распоряжайтесь результатом.
+ }
+ .build()
+val disposable = imageLoader.enqueue(request)
+
Чтобы загрузить изображение императивно, выполните execute
на ImageRequest
:
val request = ImageRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .build()
+val drawable = imageLoader.execute(request).drawable
+
Полную документацию для Coil можно найти здесь.
Coil полностью совместим с R8 "из коробки" и не требует дополнительной настройки.
Если вы используете Proguard, вам может понадобиться добавить правила для корутин и OkHttp.
Copyright 2024 Coil Contributors
+
+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
+
+ https://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.
+
Ett bildladdningsbibliotek för Android med stöd för Kotlin Coroutines. Coil är:
Coil är en förkortning för: Coroutine Image Loader.
Översättningar: 한국어, 中文, Türkçe, 日本語, Svenska
Coil finns att ladda ned från mavenCentral()
.
För att ladda in en bild i en ImageView
, använd förlängningsfunktionen load
:
// URL
+imageView.load("https://example.com/image.jpg")
+
+// Fil
+imageView.load(File("/path/to/image.jpg"))
+
+// Och mer...
+
Förfrågningar kan konfigureras med en valfri släpande lambda:
imageView.load("https://example.com/image.jpg") {
+ crossfade(true)
+ placeholder(R.drawable.image)
+ transformations(CircleCropTransformation())
+}
+
Importera Jetpack Compose-förlängningsbiblioteket:
För att ladda in en bild, använd en AsyncImage
composable:
Både imageView.load
och AsyncImage
använder singletonobjektet ImageLoader
för att genomföra bildförfrågningar. Singletonobjektet ImageLoader
kan kommas åt genom att använda en förlängningsfunktion för Context
:
ImageLoader
s är designade för att vara delbara och är mest effektiva när du skapar en enda instans och delar den i hela appen. Med det sagt, kan du även skapa din(a) egna instans(er) av ImageLoader
:
Om du inte vill använda singletonobjektet ImageLoader
, använd artefakten io.coil-kt:coil-base
istället för io.coil-kt:coil
.
För att ladda en bild till ett anpassat mål, använd metoden enqueue
på en instans av klassen ImageRequest
:
val request = ImageRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .target { drawable ->
+ // Handle the result.
+ }
+ .build()
+val disposable = imageLoader.enqueue(request)
+
För att ladda en bild imperativt, använd metoden execute
på en instans av klassen ImageRequest
:
val request = ImageRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .build()
+val drawable = imageLoader.execute(request).drawable
+
Kolla in Coils fullständiga dokumentation här.
Coil är fullt kompatibel med R8 och kräver inga särskilda extra regler.
Om du använder Proguard kan du behöva lägga till regler för Coroutines och OkHttp.
Copyright 2024 Coil Contributors
+
+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
+
+ https://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.
+
Kotlin Coroutines tarafından desteklenen Android için bir görüntü yükleme kütüphanesi. Coil şunlardır:
Coil, Coroutine Image Loader'ın kısaltmasıdır.
Çeviriler: 日本語, 한국어, Русский, Svenska, Türkçe, 中文
Coil, mavenCentral()
üzerinde mevcuttur.
Bir görüntüyü bir ImageView
'a yüklemek için load
uzantı fonksiyonunu kullanın:
// URL
+imageView.load("https://example.com/image.jpg")
+
+// Dosya
+imageView.load(File("/path/to/image.jpg"))
+
+// Ve daha fazlası...
+
İstekler, isteğe bağlı bir kapanan lambda ile yapılandırılabilir:
imageView.load("https://example.com/image.jpg") {
+ crossfade(true)
+ placeholder(R.drawable.image)
+ transformations(CircleCropTransformation())
+}
+
Jetpack Compose uzantı kütüphanesini içe aktarın:
Bir görüntü yüklemek için, AsyncImage
bileşenini kullanın:
imageView.load
ve AsyncImage
hem görüntü isteklerini yürütmek için singleton ImageLoader
'ı kullanır. Singleton ImageLoader
'a bir Context
genişletme fonksiyonu kullanarak erişilebilir:
ImageLoader
'lar paylaşılabilir olarak tasarlanmıştır ve uygulamanız boyunca tek bir örnek oluşturup paylaştığınızda en verimlidir. Bununla birlikte, kendi ImageLoader
örneğinizi de oluşturabilirsiniz:
Eğer singleton ImageLoader
istemiyorsanız, io.coil-kt:coil
yerine io.coil-kt:coil-base
bağımlılığını kullanın.
Bir görüntüyü özel bir hedefe yüklemek için bir ImageRequest
'i enqueue
edin:
val request = ImageRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .target { drawable ->
+ // Sonucu işleyin.
+ }
+ .build()
+val disposable = imageLoader.enqueue(request)
+
Bir görüntüyü mecburi bir şekilde yüklemek için bir ImageRequest
'i execute
edin:
val request = ImageRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .build()
+val drawable = imageLoader.execute(request).drawable
+
Coil'in tam belgelerini buradan inceleyin.
Coil, R8 ile uyumlu olarak kutudan çıkar ve ekstra kurallar eklemeyi gerektirmez.
Eğer Proguard kullanıyorsanız, Coroutines ve OkHttp için kurallar eklemeniz gerekebilir.
Copyright 2024 Coil Contributors
+
+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
+
+ https://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.
+
Coil 是一个 Android 图片加载库,通过 Kotlin 协程的方式加载图片。特点如下:
Coil 名字的由来:取 Coroutine Image Loader 首字母得来。
Coil 可以在 mavenCentral()
下载
可以使用 ImageView
的扩展函数 load
加载一张图片:
// URL
+imageView.load("https://example.com/image.jpg")
+
+// Resource
+imageView.load(R.drawable.image)
+
+// File
+imageView.load(File("/path/to/image.jpg"))
+
+// And more...
+
可以使用 lambda 语法轻松配置请求选项:
imageView.load("https://example.com/image.jpg") {
+ crossfade(true)
+ placeholder(R.drawable.image)
+ transformations(CircleCropTransformation())
+}
+
引入 Jetpack Compose 扩展库:
使用 AsyncImage
加载图片:
ImageLoader
¶imageView.load
使用单例 ImageLoader
来把 ImageRequest
加入队列. ImageLoader
单例可以通过扩展方法来获取:
此外,你也可以通过创建 ImageLoader
实例从而实现依赖注入:
如果你不需要 ImageLoader
作为单例,请把Gradle依赖替换成 io.coil-kt:coil-base
.
ImageRequest
¶如果想定制 ImageRequest
的加载目标,可以依照如下方式把 ImageRequest
加入队列:
val request = ImageRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .target { drawable ->
+ // Handle the result.
+ }
+ .build()
+val disposable = imageLoader.enqueue(request)
+
如果想命令式地执行图片加载,也可以直接调用 execute(ImageRequest)
:
val request = ImageRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .build()
+val drawable = imageLoader.execute(request).drawable
+
请至 Coil 的完整文档获得更多信息。
Coil 兼容 R8 混淆,您无需再添加其他的规则
如果您需要混淆代码,可能需要添加对应的混淆规则:Coroutines, OkHttp。
Copyright 2024 Coil Contributors
+
+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
+
+ https://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.
+
A state transform that does not modify the state.
The latest arguments passed to AsyncImagePainter.
The request has not been started.
The current painter being drawn by AsyncImagePainter.
The current painter being drawn by AsyncImagePainter.
The request failed due to ErrorResult.throwable.
The current painter being drawn by AsyncImagePainter.
The current painter being drawn by AsyncImagePainter.
The request is in-progress.
The current painter being drawn by AsyncImagePainter.
The request was successful.
The current painter being drawn by AsyncImagePainter.
The current painter being drawn by AsyncImagePainter.
The request has not been started.
The request failed due to ErrorResult.throwable.
The request is in-progress.
The request was successful.
The current painter being drawn by AsyncImagePainter.
The current painter being drawn by AsyncImagePainter.
A Painter that that executes an ImageRequest asynchronously and renders the ImageResult.
The latest arguments passed to AsyncImagePainter.
The current state of the AsyncImagePainter.
Convenience function that creates an AsyncImagePreviewHandler that returns an Image.
Controls what AsyncImage, SubcomposeAsyncImage, and AsyncImagePainter render when LocalInspectionMode is true.
A composable that executes an ImageRequest asynchronously and renders the result.
Either an ImageRequest or the ImageRequest.data value.
Text used by accessibility services to describe what this image represents. This should always be provided unless this image is used for decorative purposes, and does not represent a meaningful action that a user can take.
The ImageLoader that will be used to execute the request.
Modifier used to adjust the layout algorithm or draw decoration content.
A Painter that is displayed while the image is loading.
A Painter that is displayed when the image request is unsuccessful.
A Painter that is displayed when the request's ImageRequest.data is null.
Called when the image request begins loading.
Called when the image request completes successfully.
Called when the image request completes unsuccessfully.
Optional alignment parameter used to place the AsyncImagePainter in the given bounds defined by the width and height.
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 AsyncImagePainter.
Optional opacity to be applied to the AsyncImagePainter when it is rendered onscreen.
Optional ColorFilter to apply for the AsyncImagePainter when it is rendered onscreen.
Sampling algorithm applied to a bitmap when it is scaled and drawn into the destination.
If true, clips the content to its bounds. Else, it will not be clipped.
Determines the equality of model. This controls whether this composable is redrawn and a new image request is launched when the outer composable recomposes.
A composable that executes an ImageRequest asynchronously and renders the result.
Either an ImageRequest or the ImageRequest.data value.
Text used by accessibility services to describe what this image represents. This should always be provided unless this image is used for decorative purposes, and does not represent a meaningful action that a user can take.
The ImageLoader that will be used to execute the request.
Modifier used to adjust the layout algorithm or draw decoration content.
A callback to transform a new State before it's applied to the AsyncImagePainter. Typically this is used to modify the state's Painter.
Called when the state of this painter changes.
Optional alignment parameter used to place the AsyncImagePainter in the given bounds defined by the width and height.
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 AsyncImagePainter.
Optional opacity to be applied to the AsyncImagePainter when it is rendered onscreen.
Optional ColorFilter to apply for the AsyncImagePainter when it is rendered onscreen.
Sampling algorithm applied to a bitmap when it is scaled and drawn into the destination.
If true, clips the content to its bounds. Else, it will not be clipped.
Determines the equality of model. This controls whether this composable is redrawn and a new image request is launched when the outer composable recomposes.
The default EqualityDelegate used to determine equality and the hash code for the model
argument for rememberAsyncImagePainter, AsyncImage, and SubcomposeAsyncImage.
A special SizeResolver that waits until AsyncImagePainter.onDraw to return the DrawScope's size.
Determines equality between two values or a value's hash code.
A composable that draws SubcomposeAsyncImage's content with SubcomposeAsyncImageScope's properties.
The alpha for SubcomposeAsyncImageContent.
If true, applies clipToBounds to SubcomposeAsyncImageContent.
The color filter for SubcomposeAsyncImageContent.
The content description for SubcomposeAsyncImageContent.
The content scale for SubcomposeAsyncImageContent.
A scope for the children of SubcomposeAsyncImage.
The alpha for SubcomposeAsyncImageContent.
If true, applies clipToBounds to SubcomposeAsyncImageContent.
The color filter for SubcomposeAsyncImageContent.
The content description for SubcomposeAsyncImageContent.
The content scale for SubcomposeAsyncImageContent.
The painter that is drawn by SubcomposeAsyncImageContent.
A composable that draws SubcomposeAsyncImage's content with SubcomposeAsyncImageScope's properties.
The painter that is drawn by SubcomposeAsyncImageContent.
A composable that executes an ImageRequest asynchronously and renders the result.
Either an ImageRequest or the ImageRequest.data value.
Text used by accessibility services to describe what this image represents. This should always be provided unless this image is used for decorative purposes, and does not represent a meaningful action that a user can take.
The ImageLoader that will be used to execute the request.
Modifier used to adjust the layout algorithm or draw decoration content.
An optional callback to overwrite what's drawn while the image request is loading.
An optional callback to overwrite what's drawn when the image request succeeds.
An optional callback to overwrite what's drawn when the image request fails.
Called when the image request begins loading.
Called when the image request completes successfully.
Called when the image request completes unsuccessfully.
Optional alignment parameter used to place the AsyncImagePainter in the given bounds defined by the width and height.
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 AsyncImagePainter.
Optional opacity to be applied to the AsyncImagePainter when it is rendered onscreen.
Optional ColorFilter to apply for the AsyncImagePainter when it is rendered onscreen.
Sampling algorithm applied to a bitmap when it is scaled and drawn into the destination.
If true, clips the content to its bounds. Else, it will not be clipped.
Determines the equality of model. This controls whether this composable is redrawn and a new image request is launched when the outer composable recomposes.
A composable that executes an ImageRequest asynchronously and renders the result.
Either an ImageRequest or the ImageRequest.data value.
Text used by accessibility services to describe what this image represents. This should always be provided unless this image is used for decorative purposes, and does not represent a meaningful action that a user can take.
The ImageLoader that will be used to execute the request.
Modifier used to adjust the layout algorithm or draw decoration content.
A callback to transform a new State before it's applied to the AsyncImagePainter. Typically this is used to modify the state's Painter.
Called when the state of this painter changes.
Optional alignment parameter used to place the AsyncImagePainter in the given bounds defined by the width and height.
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 AsyncImagePainter.
Optional opacity to be applied to the AsyncImagePainter when it is rendered onscreen.
Optional ColorFilter to apply for the AsyncImagePainter when it is rendered onscreen.
Sampling algorithm applied to a bitmap when it is scaled and drawn into the destination.
If true, clips the content to its bounds. Else, it will not be clipped.
Determines the equality of model. This controls whether this composable is redrawn and a new image request is launched when the outer composable recomposes.
A callback to draw the content inside a SubcomposeAsyncImageScope.
Convert this Image into a Painter using Compose primitives if possible.
A Painter that that executes an ImageRequest asynchronously and renders the ImageResult.
Controls what AsyncImage, SubcomposeAsyncImage, and AsyncImagePainter render when LocalInspectionMode is true.
A special SizeResolver that waits until AsyncImagePainter.onDraw to return the DrawScope's size.
Determines equality between two values or a value's hash code.
A scope for the children of SubcomposeAsyncImage.
The default EqualityDelegate used to determine equality and the hash code for the model
argument for rememberAsyncImagePainter, AsyncImage, and SubcomposeAsyncImage.
A composable that executes an ImageRequest asynchronously and renders the result.
Convenience function that creates an AsyncImagePreviewHandler that returns an Image.
Return an AsyncImagePainter that executes an ImageRequest asynchronously and renders the result.
A composable that executes an ImageRequest asynchronously and renders the result.
A composable that draws SubcomposeAsyncImage's content with SubcomposeAsyncImageScope's properties.
Return an AsyncImagePainter that executes an ImageRequest asynchronously and renders the result.
** This is a lower-level API than AsyncImage and may not work as expected in all situations. **
Either an ImageRequest or the ImageRequest.data value.
The ImageLoader that will be used to execute the request.
A Painter that is displayed while the image is loading.
A Painter that is displayed when the image request is unsuccessful.
A Painter that is displayed when the request's ImageRequest.data is null.
Called when the image request begins loading.
Called when the image request completes successfully.
Called when the image request completes unsuccessfully.
Sampling algorithm applied to a bitmap when it is scaled and drawn into the destination.
Determines the equality of model. This controls whether this composable is redrawn and a new image request is launched when the outer composable recomposes.
Return an AsyncImagePainter that executes an ImageRequest asynchronously and renders the result.
** This is a lower-level API than AsyncImage and may not work as expected in all situations. **
Either an ImageRequest or the ImageRequest.data value.
The ImageLoader that will be used to execute the request.
A callback to transform a new State before it's applied to the AsyncImagePainter. Typically this is used to overwrite the state's Painter.
Called when the state of this painter changes.
Sampling algorithm applied to a bitmap when it is scaled and drawn into the destination.
Determines the equality of model. This controls whether this composable is redrawn and a new image request is launched when the outer composable recomposes.
A composable that executes an ImageRequest asynchronously and renders the result.
Either an ImageRequest or the ImageRequest.data value.
Text used by accessibility services to describe what this image represents. This should always be provided unless this image is used for decorative purposes, and does not represent a meaningful action that a user can take.
Modifier used to adjust the layout algorithm or draw decoration content.
A Painter that is displayed while the image is loading.
A Painter that is displayed when the image request is unsuccessful.
A Painter that is displayed when the request's ImageRequest.data is null.
Called when the image request begins loading.
Called when the image request completes successfully.
Called when the image request completes unsuccessfully.
Optional alignment parameter used to place the AsyncImagePainter in the given bounds defined by the width and height.
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 AsyncImagePainter.
Optional opacity to be applied to the AsyncImagePainter when it is rendered onscreen.
Optional ColorFilter to apply for the AsyncImagePainter when it is rendered onscreen.
Sampling algorithm applied to a bitmap when it is scaled and drawn into the destination.
If true, clips the content to its bounds. Else, it will not be clipped.
Determines the equality of model. This controls whether this composable is redrawn and a new image request is launched when the outer composable recomposes.
A composable that executes an ImageRequest asynchronously and renders the result.
Either an ImageRequest or the ImageRequest.data value.
Text used by accessibility services to describe what this image represents. This should always be provided unless this image is used for decorative purposes, and does not represent a meaningful action that a user can take.
Modifier used to adjust the layout algorithm or draw decoration content.
A callback to transform a new State before it's applied to the AsyncImagePainter. Typically this is used to modify the state's Painter.
Called when the state of this painter changes.
Optional alignment parameter used to place the AsyncImagePainter in the given bounds defined by the width and height.
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 AsyncImagePainter.
Optional opacity to be applied to the AsyncImagePainter when it is rendered onscreen.
Optional ColorFilter to apply for the AsyncImagePainter when it is rendered onscreen.
Sampling algorithm applied to a bitmap when it is scaled and drawn into the destination.
If true, clips the content to its bounds. Else, it will not be clipped.
Determines the equality of model. This controls whether this composable is redrawn and a new image request is launched when the outer composable recomposes.
A composable that executes an ImageRequest asynchronously and renders the result.
Either an ImageRequest or the ImageRequest.data value.
Text used by accessibility services to describe what this image represents. This should always be provided unless this image is used for decorative purposes, and does not represent a meaningful action that a user can take.
Modifier used to adjust the layout algorithm or draw decoration content.
An optional callback to overwrite what's drawn while the image request is loading.
An optional callback to overwrite what's drawn when the image request succeeds.
An optional callback to overwrite what's drawn when the image request fails.
Called when the image request begins loading.
Called when the image request completes successfully.
Called when the image request completes unsuccessfully.
Optional alignment parameter used to place the AsyncImagePainter in the given bounds defined by the width and height.
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 AsyncImagePainter.
Optional opacity to be applied to the AsyncImagePainter when it is rendered onscreen.
Optional ColorFilter to apply for the AsyncImagePainter when it is rendered onscreen.
Sampling algorithm applied to a bitmap when it is scaled and drawn into the destination.
If true, clips the content to its bounds. Else, it will not be clipped.
Determines the equality of model. This controls whether this composable is redrawn and a new image request is launched when the outer composable recomposes.
A composable that executes an ImageRequest asynchronously and renders the result.
Either an ImageRequest or the ImageRequest.data value.
Text used by accessibility services to describe what this image represents. This should always be provided unless this image is used for decorative purposes, and does not represent a meaningful action that a user can take.
Modifier used to adjust the layout algorithm or draw decoration content.
A callback to transform a new State before it's applied to the AsyncImagePainter. Typically this is used to modify the state's Painter.
Called when the state of this painter changes.
Optional alignment parameter used to place the AsyncImagePainter in the given bounds defined by the width and height.
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 AsyncImagePainter.
Optional opacity to be applied to the AsyncImagePainter when it is rendered onscreen.
Optional ColorFilter to apply for the AsyncImagePainter when it is rendered onscreen.
Sampling algorithm applied to a bitmap when it is scaled and drawn into the destination.
If true, clips the content to its bounds. Else, it will not be clipped.
Determines the equality of model. This controls whether this composable is redrawn and a new image request is launched when the outer composable recomposes.
A callback to draw the content inside a SubcomposeAsyncImageScope.
A composable that executes an ImageRequest asynchronously and renders the result.
Return an AsyncImagePainter that executes an ImageRequest asynchronously and renders the result.
Alias for SingletonImageLoader.setSafe that's optimized for calling from Compose.
A composable that executes an ImageRequest asynchronously and renders the result.
Return an AsyncImagePainter that executes an ImageRequest asynchronously and renders the result.
** This is a lower-level API than AsyncImage and may not work as expected in all situations. **
Either an ImageRequest or the ImageRequest.data value.
A Painter that is displayed while the image is loading.
A Painter that is displayed when the image request is unsuccessful.
A Painter that is displayed when the request's ImageRequest.data is null.
Called when the image request begins loading.
Called when the image request completes successfully.
Called when the image request completes unsuccessfully.
Sampling algorithm applied to a bitmap when it is scaled and drawn into the destination.
Determines the equality of model. This controls whether this composable is redrawn and a new image request is launched when the outer composable recomposes.
Return an AsyncImagePainter that executes an ImageRequest asynchronously and renders the result.
** This is a lower-level API than AsyncImage and may not work as expected in all situations. **
Either an ImageRequest or the ImageRequest.data value.
A callback to transform a new State before it's applied to the AsyncImagePainter. Typically this is used to overwrite the state's Painter.
Called when the state of this painter changes.
Sampling algorithm applied to a bitmap when it is scaled and drawn into the destination.
Determines the equality of model. This controls whether this composable is redrawn and a new image request is launched when the outer composable recomposes.
Alias for SingletonImageLoader.setSafe that's optimized for calling from Compose.
Marks declarations that should be used carefully.
Targets marked by this annotation are often provided for usage in tests and should be avoided in production code.
Marks declarations that are still experimental.
Targets marked by this annotation may contain breaking changes in the future as their design is still incubating.
Marks declarations that are internal in Coil's API.
Targets marked by this annotation should not be used outside of Coil because their signatures and semantics will change between future releases without any warnings and without providing any migration aids.
Marks declarations that should be used carefully.
Marks declarations that are still experimental.
Marks declarations that are internal in Coil's API.
Metadata containing the filePath of an Android asset.
The base Decoder that uses BitmapFactory to decode a given ImageSource.
Metadata containing the underlying ByteBuffer of the ImageSource.
Metadata containing the uri and associated assetFileDescriptor of a content
URI.
Represents a disk-based data source (e.g. DrawableRes
, File
).
Represents an in-memory data source (e.g. Bitmap
, ByteBuffer
).
Represents an ImageLoader's memory cache.
This is a special data source as it means the request was short circuited and skipped the full image pipeline.
Represents a network-based data source (e.g. Url
).
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
Represents the source that an image was loaded from.
Represents an ImageLoader's memory cache.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Returns an array containing the constants of this enum type, in the order they're declared.
This method may be used to iterate over the constants.
The result of Decoder.decode.
The decoded Image.
'true' if image is sampled (i.e. loaded into memory at less than its original size).
Parse targetSize and return the destination dimensions that the source image should be scaled into. The returned dimensions can be passed to computeSizeMultiplier to get the final size multiplier.
Calculate the percentage to multiply the source dimensions by to fit/fill the destination dimensions while preserving aspect ratio.
A collection of useful utility methods for decoding images.
Parse targetSize and return the destination dimensions that the source image should be scaled into. The returned dimensions can be passed to computeSizeMultiplier to get the final size multiplier.
Calculate the percentage to multiply the source dimensions by to fit/fill the destination dimensions while preserving aspect ratio.
Return a Decoder that can decode result or 'null' if this factory cannot create a decoder for the source.
Implementations must not consume result's ImageSource, as this can cause calls to subsequent decoders to fail. ImageSources should only be consumed in decode.
Prefer using BufferedSource.peek, BufferedSource.rangeEquals, or other non-consuming methods to check for the presence of header bytes or other markers. Implementations can also rely on SourceFetchResult.mimeType, however it is not guaranteed to be accurate (e.g. a file that ends with .png, but is encoded as a .jpg).
The result from the Fetcher.
A set of configuration options for this request.
The ImageLoader that's executing this request.
Decode the SourceFetchResult provided by Factory.create or return 'null' to delegate to the next Factory in the component registry.
A Decoder converts a SourceFetchResult into a DecodeResult.
Use this interface to add support for custom file formats (e.g. GIF, SVG, TIFF, etc.).
Decode the SourceFetchResult provided by Factory.create or return 'null' to delegate to the next Factory in the component registry.
Ignore the EXIF orientation flag.
Respect the EXIF orientation flag for all supported formats.
NOTE: This strategy can potentially cause out of memory errors as certain image formats (e.g. PNG) will be buffered entirely into memory while being decoded.
Respect the EXIF orientation flag only for image formats that won't negatively affect performance.
This strategy respects the EXIF orientation flag for the following MIME types:
image/jpeg
image/webp
image/heic
image/heif
This is the default value for ImageLoader.Builder.bitmapFactoryExifOrientationStrategy.
Ignore the EXIF orientation flag.
Respect the EXIF orientation flag for all supported formats.
Respect the EXIF orientation flag only for image formats that won't negatively affect performance.
Return true if the image should be normalized according to its EXIF data.
NOTE: It is an error to consume source. Use BufferedSource.peek, BufferedSource.rangeEquals, or other non-consuming methods to read the source.
Create a new ImageSource backed by a Path.
The file to read from.
The file system which contains file.
An optional cache key for the file in the disk cache.
An optional closeable reference that will be closed when the image source is closed.
Metadata for this image source.
Create a new ImageSource backed by a BufferedSource.
The buffered source to read from.
The file system which will be used to create a temporary file if necessary.
Metadata for this image source.
A marker class for metadata for an ImageSource.
Heavily prefer using source or file to decode the image's data instead of relying on information provided in the metadata. It's the responsibility of a Fetcher to create a BufferedSource or Path that can be easily read irrespective of where the image data is located. A Decoder should be as decoupled as possible from where the image is being fetched from.
This method is provided as a way to pass information to decoders that don't support decoding a BufferedSource and want to avoid creating a temporary file (e.g. ImageDecoder
, MediaMetadataRetriever
).
Return a Path that resolves to a file containing this ImageSource's data if one has already been created. Else, return 'null'.
The FileSystem which contains the file.
Return a Path that resolves to a file containing this ImageSource's data.
If this image source is backed by a BufferedSource, a temporary file containing this ImageSource's data will be created.
Provides access to the image data to be decoded.
A marker class for metadata for an ImageSource.
The FileSystem which contains the file.
Return the Metadata for this ImageSource.
Return a Path that resolves to a file containing this ImageSource's data.
Return a Path that resolves to a file containing this ImageSource's data if one has already been created. Else, return 'null'.
Return a BufferedSource to read this ImageSource.
Return the BufferedSource to read this ImageSource if one has already been created. Else, return 'null'.
Return the Metadata for this ImageSource.
Return the BufferedSource to read this ImageSource if one has already been created. Else, return 'null'.
Return a BufferedSource to read this ImageSource.
Metadata containing the packageName, resId, and density of an Android resource.
Return a Decoder that can decode result or 'null' if this factory cannot create a decoder for the source.
Implementations must not consume result's ImageSource, as this can cause calls to subsequent decoders to fail. ImageSources should only be consumed in decode.
Prefer using BufferedSource.peek, BufferedSource.rangeEquals, or other non-consuming methods to check for the presence of header bytes or other markers. Implementations can also rely on SourceFetchResult.mimeType, however it is not guaranteed to be accurate (e.g. a file that ends with .png, but is encoded as a .jpg).
The result from the Fetcher.
A set of configuration options for this request.
The ImageLoader that's executing this request.
Decode the SourceFetchResult provided by Factory.create or return 'null' to delegate to the next Factory in the component registry.
Decode the SourceFetchResult provided by Factory.create or return 'null' to delegate to the next Factory in the component registry.
Metadata containing the filePath of an Android asset.
The base Decoder that uses BitmapFactory to decode a given ImageSource.
Metadata containing the underlying ByteBuffer of the ImageSource.
Metadata containing the uri and associated assetFileDescriptor of a content
URI.
Represents the source that an image was loaded from.
A Decoder converts a SourceFetchResult into a DecodeResult.
The result of Decoder.decode.
A collection of useful utility methods for decoding images.
Specifies the strategy for handling the EXIF orientation flag.
Provides access to the image data to be decoded.
Metadata containing the packageName, resId, and density of an Android resource.
Create a new ImageSource backed by a BufferedSource.
Create a new ImageSource backed by a Path.
Set the CoroutineDispatcher that cache size trim operations will be executed on.
Set the fileSystem where the cache stores its data.
Set the CoroutineDispatcher that cache size trim operations will be executed on.
Set the directory where the cache stores its data.
Set the directory where the cache stores its data.
Set the fileSystem where the cache stores its data.
Set the maximum size of the disk cache in bytes. This is ignored if maxSizeBytes is set.
Set the maximum size of the disk cache in bytes.
Set the maximum size of the disk cache as a percentage of the device's free disk space.
Set the minimum size of the disk cache in bytes. This is ignored if maxSizeBytes is set.
Set the maximum size of the disk cache in bytes.
Set the maximum size of the disk cache as a percentage of the device's free disk space.
Set the maximum size of the disk cache in bytes. This is ignored if maxSizeBytes is set.
Set the minimum size of the disk cache in bytes. This is ignored if maxSizeBytes is set.
Abort the edit. Any written data will be discarded.
Commit the write and call openSnapshot for this entry atomically.
Commit the edit so the changes are visible to readers.
Edits the values for an entry.
Calling metadata or data marks that file as dirty so it will be persisted to disk if this editor is committed.
IMPORTANT: You must only read or modify the contents of metadata or data. Renaming, locking, or other mutating file operations can corrupt the disk cache.
Commit the write and call openSnapshot for this entry atomically.
Close the snapshot and call openEditor for this entry atomically.
Close the snapshot to allow editing.
A snapshot of the values for an entry.
IMPORTANT: You must only read metadata or data. Mutating either file can corrupt the disk cache. To modify the contents of those files, use openEditor.
Close the snapshot and call openEditor for this entry atomically.
Delete all entries in the disk cache.
The file system that contains the cache's files.
An LRU cache of files.
Write to the entry associated with key.
IMPORTANT: You must call one of Editor.commit, Editor.commitAndOpenSnapshot, or Editor.abort to complete the edit. An open editor prevents opening a new Snapshot, opening a new Editor, or deleting the entry on disk.
Read the entry associated with key.
IMPORTANT: You must call either Snapshot.close or Snapshot.closeAndOpenEditor when finished reading the snapshot. An open snapshot prevents opening a new Editor or deleting the entry on disk.
Close any open snapshots, abort all in-progress edits, and close any open system resources.
Set the directory where the cache stores its data.
IMPORTANT: It is an error to have two DiskCache instances active in the same directory at the same time as this can corrupt the disk cache.
Set the directory where the cache stores its data.
Return a Fetcher that can fetch data or 'null' if this factory cannot create a fetcher for the data.
The data to fetch.
A set of configuration options for this request.
The ImageLoader that's executing this request.
Fetch the data provided by Factory.create or return 'null' to delegate to the next Factory in the component registry.
A Fetcher translates data (e.g. URI, file, etc.) into a FetchResult.
To accomplish this, fetchers fit into one of two types:
Uses the data as a key to fetch bytes from a remote source (e.g. network, disk) and exposes it as an ImageSource.
Reads the data directly and translates it into an Image.
Fetch the data provided by Factory.create or return 'null' to delegate to the next Factory in the component registry.
An Image result. Return this from a Fetcher if its data cannot be converted into an ImageSource.
The ImageSource to read from.
An optional MIME type for the source.
The source that source was fetched from.
An ImageSource result, which will be consumed by a relevant Decoder.
The ImageSource to read from.
An optional MIME type for the source.
The source that source was fetched from.
A Fetcher translates data (e.g. URI, file, etc.) into a FetchResult.
The result of Fetcher.fetch.
An Image result. Return this from a Fetcher if its data cannot be converted into an ImageSource.
An ImageSource result, which will be consumed by a relevant Decoder.
Continue executing the chain.
Observe, transform, short circuit, or retry requests to an ImageLoader's image engine.
Observe, transform, short circuit, or retry requests to an ImageLoader's image engine.
An interface to convert data of type T into a string key for the memory cache.
Create a new MemoryCache instance.
Create a new MemoryCache instance.
Set the maximum size of the memory cache in bytes.
Set the maximum size of the memory cache as a percentage of this application's available memory.
Enables/disables strong reference tracking of values added to this memory cache.
Enables/disables weak reference tracking of values added to this memory cache. Weak references do not contribute to the current size of the memory cache. This ensures that if a Value hasn't been garbage collected yet it will be returned from the memory cache.
Set the maximum size of the memory cache in bytes.
Set the maximum size of the memory cache as a percentage of this application's available memory.
Enables/disables strong reference tracking of values added to this memory cache.
Enables/disables weak reference tracking of values added to this memory cache. Weak references do not contribute to the current size of the memory cache. This ensures that if a Value hasn't been garbage collected yet it will be returned from the memory cache.
The cache key for a Value in the memory cache.
Remove all values from the memory cache.
An LRU cache of Images.
Remove the eldest entries until the cache's size is at or below size.
The keys present in the cache.
Remove the eldest entries until the cache's size is at or below size.
An LRU cache of Images.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
Represents the read/write policy for a cache source.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Returns an array containing the constants of this enum type, in the order they're declared.
This method may be used to iterate over the constants.
Cancels this disposable's work and releases any held resources.
Represents the work of an ImageRequest that has been executed by an ImageLoader.
Returns 'true' if this disposable's work is complete or cancelling.
The most recent image request job. This field is not immutable and can change if the request is replayed.
Indicates that an error occurred while executing the request.
The request that was executed to create this result.
A Lifecycle implementation that is always resumed and never destroyed.
This is used as a fallback if getLifecycle cannot find a more tightly scoped Lifecycle.
Create a new ImageRequest.
Set the data to load.
Use factory to handle decoding any image data.
If this is null or is not set the ImageLoader will find an applicable decoder in its ComponentRegistry.
Set the defaults for any unset request values.
Set the disk cache key for this request.
If this is null or is not set, the ImageLoader will compute a disk cache key.
Enable/disable reading/writing from/to the disk cache.
Set the error image to use if the request fails.
Set the fallback image to use if data is null.
Use factory to handle fetching any image data.
If this is null or is not set the ImageLoader will find an applicable fetcher in its ComponentRegistry.
The FileSystem that will be used to perform any disk read/write operations.
Create a new ImageRequest.
Enable a crossfade animation when a request completes successfully.
Enable a crossfade animation when a request completes successfully.
Set the data to load.
Use factory to handle decoding any image data.
Set the defaults for any unset request values.
Set the disk cache key for this request.
Enable/disable reading/writing from/to the disk cache.
Set the error image to use if the request fails.
Set the fallback image to use if data is null.
Use factory to handle fetching any image data.
The FileSystem that will be used to perform any disk read/write operations.
Set the Listener.
Convenience function to create and set the Listener.
Set the maximum width and height for a bitmap.
Set the memory cache key for this request.
Set extra values to be added to this image request's memory cache key.
Set extra values to be added to this image request's memory cache key.
Enable/disable reading/writing from/to the memory cache.
Enable/disable reading from the network.
Set the placeholder image to use when the request starts.
Set the precision for the size of the loaded image.
Set the scaling algorithm that will be used to fit/fill the image into the size provided by sizeResolver.
Set the requested width/height.
Set the SizeResolver to resolve the requested width/height.
Convenience function to create and set the Listener.
Set the Listener.
Set extra values to be added to this image request's memory cache key.
Set extra values to be added to this image request's memory cache key.
Set the memory cache key for this request.
If this is null or is not set, the ImageLoader will compute a memory cache key.
Enable/disable reading/writing from/to the memory cache.
Enable/disable reading from the network.
NOTE: Disabling writes has no effect.
Set the memory cache key whose value will be used as the placeholder drawable.
If there is no value in the memory cache for key, fall back to placeholder.
Set the memory cache key whose value will be used as the placeholder image.
If there is no value in the memory cache for key, fall back to placeholder.
Set the placeholder image to use when the request starts.
Set the precision for the size of the loaded image.
NOTE: If size is Size.ORIGINAL, the returned image's size will always be equal to or greater than the image's original size.
Set the scaling algorithm that will be used to fit/fill the image into the size provided by sizeResolver.
A set of default options that are used to fill in unset ImageRequest values.
Tracks which values have been set (instead of computed automatically using a default) when building an ImageRequest.
Called if the request is cancelled.
Called if an error occurs while executing the request.
Called immediately after Target.onStart.
Called if the request completes successfully.
Called if the request is cancelled.
Called if an error occurs while executing the request.
Called immediately after Target.onStart.
Called if the request completes successfully.
The defaults used to fill unset values.
The raw values set on Builder.
An immutable value object that represents a request for an image.
A set of default options that are used to fill in unset ImageRequest values.
Tracks which values have been set (instead of computed automatically using a default) when building an ImageRequest.
A set of callbacks for an ImageRequest.
The defaults used to fill unset values.
The raw values set on Builder.
Create and return a new placeholder image.
Exception thrown when an ImageRequest with empty/null data is executed by an ImageLoader.
The value for ImageRequest.data if the request's data was not set or was set to null.
The PlatformContext used to execute this request.
The cache key to use when persisting images to the disk cache or 'null' if the component can compute its own.
Determines if this request is allowed to read/write from/to disk.
The FileSystem that will be used to perform any disk read/write operations.
A set of configuration options for fetching and decoding an image.
Fetchers and Decoders should respect these options as best as possible.
The PlatformContext used to execute this request.
The cache key to use when persisting images to the disk cache or 'null' if the component can compute its own.
Determines if this request is allowed to read/write from/to disk.
The FileSystem that will be used to perform any disk read/write operations.
Determines if this request is allowed to read/write from/to memory.
Determines if this request is allowed to read from the network.
Precision.EXACT if the output image needs to fit/fill the target's dimensions exactly.
Determines if this request is allowed to read/write from/to memory.
Determines if this request is allowed to read from the network.
Precision.EXACT if the output image needs to fit/fill the target's dimensions exactly.
For instance, if Precision.INEXACT BitmapFactoryDecoder
will not decode an image at a larger size than its source dimensions as an optimization.
The data source that the image was loaded from.
The cache key for the image in the disk cache. It is 'null' if the image was not written to the disk cache.
Indicates that the request completed successfully.
The data source that the image was loaded from.
The cache key for the image in the disk cache. It is 'null' if the image was not written to the disk cache.
'true' if ImageRequest.placeholderMemoryCacheKey was present in the memory cache.
The cache key for the image in the memory cache. It is 'null' if the image was not written to the memory cache.
The request that was executed to create this result.
'true' if ImageRequest.placeholderMemoryCacheKey was present in the memory cache.
The cache key for the image in the memory cache. It is 'null' if the image was not written to the memory cache.
The request that was executed to create this result.
Allow converting the result drawable to a bitmap to apply any transformations.
If false and the result drawable is not a BitmapDrawable any transformations will be ignored.
Allow the use of Bitmap.Config.HARDWARE.
If false, any use of Bitmap.Config.HARDWARE will be treated as Bitmap.Config.ARGB_8888.
NOTE: Setting this to false this will reduce performance on API 26 and above. Only disable this if necessary.
Allow automatically using Bitmap.Config.RGB_565 when an image is guaranteed to not have alpha.
This will reduce the visual quality of the image, but will also reduce memory usage.
Prefer only enabling this for low memory and resource constrained devices.
Set the preferred Bitmap.Config.
This is not guaranteed and a different bitmap config may be used in some situations.
Set the preferred ColorSpace.
This is not guaranteed and a different color space may be used in some situations.
Enable a crossfade animation when a request completes successfully.
Enable a crossfade animation when a request completes successfully.
Represents the read/write policy for a cache source.
Represents the work of an ImageRequest that has been executed by an ImageLoader.
Indicates that an error occurred while executing the request.
A Lifecycle implementation that is always resumed and never destroyed.
An immutable value object that represents a request for an image.
Represents the result of an executed ImageRequest.
The value for ImageRequest.data if the request's data was not set or was set to null.
Exception thrown when an ImageRequest with empty/null data is executed by an ImageLoader.
A set of configuration options for fetching and decoding an image.
Indicates that the request completed successfully.
Allow converting the result drawable to a bitmap to apply any transformations.
Allow the use of Bitmap.Config.HARDWARE.
Allow automatically using Bitmap.Config.RGB_565 when an image is guaranteed to not have alpha.
Set the preferred Bitmap.Config.
Set the preferred ColorSpace.
Enable a crossfade animation when a request completes successfully.
Enable a crossfade animation when a request completes successfully.
Set the maximum width and height for a bitmap.
Enable/disable pre-multiplication of the color (RGB) channels of the decoded image by the alpha channel.
Set Transformations to be applied to the output image.
Set the Transition.Factory that's started when an image result is applied to a target.
Set the Lifecycle for this request.
Requests are queued while the lifecycle is not at least Lifecycle.State.STARTED. Requests are cancelled when the lifecycle reaches Lifecycle.State.DESTROYED.
If this is null or is not set the ImageLoader will attempt to find the lifecycle for this request through ImageRequest.context.
Set the maximum width and height for a bitmap.
This value is cooperative and Fetchers and Decoders should respect the width and height values provided by maxBitmapSize and not allocate a bitmap with a width/height larger than those dimensions.
To allow a bitmap's size to be unrestricted pass Dimension.Undefined for size's width and/or height.
Enable/disable pre-multiplication of the color (RGB) channels of the decoded image by the alpha channel.
The default behavior is to enable pre-multiplication but in some environments it can be necessary to disable this feature to leave the source pixels unmodified.
Set Transformations to be applied to the output image.
Set the Transition.Factory that's started when an image result is applied to a target.
Create a Dimension.Pixels value with px number of pixels.
Represents an undefined pixel value.
E.g. given Size(400, Dimension.Undefined)
, the image should be loaded to fit/fill a width of 400 pixels irrespective of the image's height.
This value is typically used in cases where a dimension is unbounded (e.g. ViewGroup.LayoutParams.WRAP_CONTENT
, Constraints.Infinity
).
NOTE: If either dimension is Undefined, Options.scale is always Scale.FIT.
Require that the loaded image's dimensions match the request's size and scale exactly.
Allow the size of the loaded image to not match the requested dimensions exactly. This enables several optimizations:
If the requested dimensions are larger than the original size of the image, it will be loaded using its original dimensions. This uses less memory.
If the image is present in the memory cache at a larger size than the request's dimensions, it will be returned. This increases the hit rate of the memory cache.
Prefer this option if your target can scale the loaded image (e.g. ImageView
, AsyncImage
).
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
Represents the required precision for the size of an image in an image request.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
A Drawable that centers and scales its child to fill its bounds.
This allows drawables that only draw within their intrinsic dimensions to fill their entire bounds.
Fill the image in the view such that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
An ImageRequest's scale determines how the source image is scaled to fit into the Size returned by ImageRequest.sizeResolver.
Conceptually, you can think of this as ImageView.ScaleType
without any knowledge of an image's gravity in the view.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Create a SizeResolver with a fixed size.
An interface for measuring the target size for an image request.
Return the Size that the image should be loaded at.
Represents the target size of an image request.
Each Size is composed of two Dimensions, width and height. Each dimension determines by how much the source image should be scaled. A Dimension can either be a fixed pixel value or Dimension.Undefined. Examples:
Given Size(400, 600)
, the image should be loaded to fit/fill a width of 400 pixels and a height of 600 pixels.
Given Size(400, Dimension.Undefined)
, the image should be loaded to fit/fill a width of 400 pixels.
Given Size(Dimension.Undefined, Dimension.Undefined)
, the image should not be scaled to fit/fill either width or height. i.e. it will be loaded at its original width/height.
Return true if this size is equal to Size.ORIGINAL. Else, return false.
Create a ViewSizeResolver using the default View measurement implementation.
The view to measure.
If true, the view's padding will be subtracted from its size.
If true, the view's padding will be subtracted from its size.
An ImageRequest's scale determines how the source image is scaled to fit into the Size returned by ImageRequest.sizeResolver.
An interface for measuring the target size for an image request.
A SizeResolver that measures the size of a View.
Return true if this size is equal to Size.ORIGINAL. Else, return false.
Create a Dimension.Pixels value with px number of pixels.
Create a SizeResolver with a fixed size.
Create a ViewSizeResolver using the default View measurement implementation.
Return true if this size is equal to Size.ORIGINAL. Else, return false.
An opinionated ViewTarget that simplifies updating the Drawable attached to a View and supports automatically starting and stopping animated Drawables.
If you need custom behaviour that this class doesn't support it's recommended to implement ViewTarget directly.
A callback that accepts an image.
A Target with an associated View. Prefer this to Target if the given drawables will only be used by view.
Optionally, ViewTargets can implement LifecycleObserver. They are automatically registered when the request starts and unregistered when the request completes.
An opinionated ViewTarget that simplifies updating the Drawable attached to a View and supports automatically starting and stopping animated Drawables.
A Transformation that crops an image using a centered circle as the mask.
If you're using Jetpack Compose, use Modifier.clip(CircleShape)
instead of this transformation as it's more efficient.
The radius for the top left corner.
The radius for the top right corner.
The radius for the bottom left corner.
The radius for the bottom right corner.
A Transformation that crops the image to fit the target's dimensions and rounds the corners of the image.
If you're using Jetpack Compose, use Modifier.clip(RoundedCornerShape(radius))
instead of this transformation as it's more efficient.
The radius for the top left corner.
The radius for the top right corner.
The radius for the bottom left corner.
The radius for the bottom right corner.
An interface for making transformations to an image's pixel data.
NOTE: If ImageFetchResult.image or DecodeResult.image is not a BitmapDrawable, it will be converted to one. This will cause animated drawables to only draw the first frame of their animation.
A Transformation that crops an image using a centered circle as the mask.
A Transformation that crops the image to fit the target's dimensions and rounds the corners of the image.
An interface for making transformations to an image's pixel data.
A Drawable that crossfades from start to end.
NOTE: The animation can only be executed once as the start drawable is dereferenced at the end of the transition.
The duration of the animation in milliseconds.
A Transition that crossfades from the current drawable to a new one.
The duration of the animation in milliseconds.
Start the transition animation.
Implementations are responsible for calling the correct Target lifecycle callback. See CrossfadeTransition for an example.
A Target that supports applying Transitions.
A class to animate between a Target's current drawable and the result of an image request.
NOTE: A Target must implement TransitionTarget to support applying Transitions. If the Target does not implement TransitionTarget, any Transitions will be ignored.
Start the transition animation.
Implementations are responsible for calling the correct Target lifecycle callback. See CrossfadeTransition for an example.
A Transition that crossfades from the current drawable to a new one.
A class to animate between a Target's current drawable and the result of an image request.
A Target that supports applying Transitions.
Public utility methods for Coil.
A Logger implementation that writes to the platform's default logging mechanism.
NOTE: You should not enable this in release builds. Adding this to your image loader reduces performance. Additionally, this will log URLs which can contain personally identifiable information.
The minimum level for this logger to log.
An efficient container to store two Ints.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
The priority level for a log message.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Returns an array containing the constants of this enum type, in the order they're declared.
This method may be used to iterate over the constants.
The minimum level for this logger to log.
A Logger implementation that writes to the platform's default logging mechanism.
An efficient container to store two Ints.
Logging interface for ImageLoaders.
Convert null and Bitmap.Config.HARDWARE configs to Bitmap.Config.ARGB_8888.
Convert null and Bitmap.Config.HARDWARE configs to Bitmap.Config.ARGB_8888.
True if the image can be shared between multiple Targets at the same time.
For example, a bitmap can be shared between multiple targets if it's immutable. Conversely, an animated image cannot be shared as its internal state is being mutated while its animation is running.
True if the image can be shared between multiple Targets at the same time.
For example, a bitmap can be shared between multiple targets if it's immutable. Conversely, an animated image cannot be shared as its internal state is being mutated while its animation is running.
A graphics surface that can be drawn on.
Register a factory of Decoder.Factorys.
Register a factory of Fetcher.Factorys.
Append an Interceptor to the end of the list.
Register a Mapper.
Register a Keyer.
Register a Fetcher.Factory.
Register a Decoder.Factory.
Register a Decoder.Factory.
Register a Fetcher.Factory.
Append an Interceptor to the end of the list.
Register a Keyer.
Register a Mapper.
Register a factory of Decoder.Factorys.
Register a factory of Fetcher.Factorys.
Registry for all the components that an ImageLoader uses to fulfil image requests.
Use this class to register support for custom Interceptors, Mappers, Keyers, Fetchers, and Decoders.
Create a new Decoder using the registered decoderFactories.
Create a new Fetcher using the registered fetcherFactories.
Create a new Decoder using the registered decoderFactories.
A Pair where the first element is the new Decoder and the second element is the index of the factory in decoderFactories that created it. Returns 'null' if a Decoder cannot be created for result.
Create a new Fetcher using the registered fetcherFactories.
A Pair where the first element is the new Fetcher and the second element is the index of the factory in fetcherFactories that created it. Returns 'null' if a Fetcher cannot be created for data.
Implement this on your Drawable implementation to provide a custom Image.size.
An Image backed by an Android Drawable.
Implement this on your Drawable implementation to provide a custom Image.size.
Called after Decoder.decode.
This is skipped if Fetcher.fetch does not return a SourceFetchResult.
The Decoder that was used to handle the request.
The Options that were passed to Decoder.decode.
The result of Decoder.decode.
Called before Decoder.decode.
This is skipped if Fetcher.fetch does not return a SourceFetchResult.
The Decoder that will be used to handle the request.
The Options that will be passed to Decoder.decode.
Called after Fetcher.fetch.
The Fetcher that was used to handle the request.
The Options that were passed to Fetcher.fetch.
The result of Fetcher.fetch.
Called before Fetcher.fetch.
The Fetcher that will be used to handle the request.
The Options that will be passed to Fetcher.fetch.
A listener for tracking the progress of an image request. This class is useful for measuring analytics, performance, or other metrics tracking.
Called after Decoder.decode.
Called before Decoder.decode.
Called after Fetcher.fetch.
Called before Fetcher.fetch.
Called after Keyer.key.
Called before Keyer.key.
Called after Mapper.map.
Called before Mapper.map.
Called if the request is cancelled.
Called if an error occurs while executing the request.
Called immediately after Target.onStart.
Called if the request completes successfully.
Called after SizeResolver.size.
Called before SizeResolver.size.
Called after any Transformations are applied.
Called before any Transformations are applied.
Called after Transition.transition.
Called before Transition.transition.
Called after Mapper.map.
The data after it has been converted. If there were no applicable mappers, output will be the same as ImageRequest.data.
Called if the request is cancelled.
Called if an error occurs while executing the request.
Called immediately after Target.onStart.
Called if the request completes successfully.
Called before SizeResolver.size.
The SizeResolver that will be used to get the Size for this request.
Called after any Transformations are applied.
This is skipped if ImageRequest.transformations
is empty.
The Image that was transformed.
Called before any Transformations are applied.
This is skipped if ImageRequest.transformations
is empty.
The Image that will be transformed.
Called after Transition.transition.
This is skipped if transition is a NoneTransition or ImageRequest.target does not implement TransitionTarget.
Called before Transition.transition.
This is skipped if transition is a NoneTransition or ImageRequest.target does not implement TransitionTarget.
Public to support static extensions.
A Drawable backed by a generic Image.
Create a new ImageLoader without configuration.
Create a new ImageLoader instance.
A convenience method to set interceptorCoroutineContext, fetcherCoroutineContext, and decoderCoroutineContext in one call.
The CoroutineContext that Decoder.decode will be executed in.
Default: Dispatchers.IO
Set the default disk cache policy.
Set the DiskCache.
NOTE: By default, ImageLoaders share the same disk cache instance. This is necessary as having multiple disk cache instances active in the same directory at the same time can corrupt the disk cache.
Set a lazy callback to create the DiskCache.
Prefer using this instead of diskCache(DiskCache)
.
NOTE: By default, ImageLoaders share the same disk cache instance. This is necessary as having multiple disk cache instances active in the same directory at the same time can corrupt the disk cache.
Set the default error image to use when a request fails.
Set the EventListener.Factory to create per-request EventListeners.
Set a single EventListener that will receive all callbacks for requests launched by this image loader.
Set the default fallback image to use if ImageRequest.data is null.
The CoroutineContext that Fetcher.fetch will be executed in.
Default: Dispatchers.IO
Set the default FileSystem for any image requests.
Enables adding a file's last modified timestamp to the memory cache key when loading an image from a file.
Create a new ImageLoader instance.
Set the ComponentRegistry.
Build and set the ComponentRegistry.
A convenience method to set interceptorCoroutineContext, fetcherCoroutineContext, and decoderCoroutineContext in one call.
The CoroutineContext that Decoder.decode will be executed in.
Set the default disk cache policy.
Set the default error image to use when a request fails.
Set a single EventListener that will receive all callbacks for requests launched by this image loader.
Set the EventListener.Factory to create per-request EventListeners.
Set the default fallback image to use if ImageRequest.data is null.
The CoroutineContext that Fetcher.fetch will be executed in.
Set the default FileSystem for any image requests.
The CoroutineContext that the Interceptor chain will be executed in.
Set the Logger to write logs to.
Set the MemoryCache.
Set a lazy callback to create the MemoryCache.
Set the default memory cache policy.
Set the default network cache policy.
Set the default placeholder image to use when a request starts.
Set the default precision for a request. Precision controls whether the size of the loaded image must match the request's size exactly or not.
Enables adding all components (fetchers and decoders) that are supported by the service locator to this ImageLoader's ComponentRegistry. All of Coil's first party decoders and fetchers are supported.
The CoroutineContext that the Interceptor chain will be executed in.
Default: EmptyCoroutineContext
Set the default memory cache policy.
Set the MemoryCache.
Set a lazy callback to create the MemoryCache.
Prefer using this instead of memoryCache(MemoryCache)
.
Set the default network cache policy.
NOTE: Disabling writes has no effect.
Set the default placeholder image to use when a request starts.
Set the default precision for a request. Precision controls whether the size of the loaded image must match the request's size exactly or not.
Default: Precision.EXACT
The components used to fulfil image requests.
The default values that are used to fill in unset ImageRequest values.
Enqueue the request to be executed asynchronously.
A Disposable which can be used to cancel or check the status of the request.
The request to execute.
Execute the request in the current coroutine scope.
A SuccessResult if the request completes successfully. Else, returns an ErrorResult.
The request to execute.
A service class that loads images by executing ImageRequests. Image loaders handle caching, data fetching, image decoding, request management, memory management, and more.
Image loaders are designed to be shareable and work best when you create a single instance and share it throughout your app.
The components used to fulfil image requests.
The default values that are used to fill in unset ImageRequest values.
An in-memory cache of previously loaded images.
Enqueue the request to be executed asynchronously.
Execute the request in the current coroutine scope.
Execute the request and block the current thread until it completes.
Create an ImageLoader.Builder that shares the same resources and configuration as this image loader.
Cancel any new and in progress requests, clear the MemoryCache, and close any open system resources.
An in-memory cache of previously loaded images.
Create an ImageLoader.Builder that shares the same resources and configuration as this image loader.
Cancel any new and in progress requests, clear the MemoryCache, and close any open system resources.
True if the image can be shared between multiple Targets at the same time.
For example, a bitmap can be shared between multiple targets if it's immutable. Conversely, an animated image cannot be shared as its internal state is being mutated while its animation is running.
Represents a platform-specific context that acts as an interface to global information about an application environment.
Enables adding a file's last modified timestamp to the memory cache key when loading an image from a file.
This allows subsequent requests that load the same file to miss the memory cache if the file has been updated. However, if the memory cache check occurs on the main thread (see ImageLoader.Builder.interceptorCoroutineContext) calling this will cause a strict mode violation.
Sets the strategy for handling the EXIF orientation flag for images decoded by BitmapFactoryDecoder.
Sets the maximum number of parallel BitmapFactory or ImageDecoder decode operations at once.
Increasing this number will allow more parallel decode operations, however it can result in worse UI performance.
Execute the request and block the current thread until it completes.
Returns the URI's Uri.path formatted according to the URI's native Uri.separator.
A grid of pixels.
A graphics surface that can be drawn on.
Registry for all the components that an ImageLoader uses to fulfil image requests.
An Image backed by an Android Drawable.
A listener for tracking the progress of an image request. This class is useful for measuring analytics, performance, or other metrics tracking.
A Drawable backed by a generic Image.
A service class that loads images by executing ImageRequests. Image loaders handle caching, data fetching, image decoding, request management, memory management, and more.
Represents a platform-specific context that acts as an interface to global information about an application environment.
Return the separate segments of the Uri.path.
Enables adding a file's last modified timestamp to the memory cache key when loading an image from a file.
Sets the strategy for handling the EXIF orientation flag for images decoded by BitmapFactoryDecoder.
Sets the maximum number of parallel BitmapFactory or ImageDecoder decode operations at once.
Execute the request and block the current thread until it completes.
Create a new ImageLoader without configuration.
Enables adding all components (fetchers and decoders) that are supported by the service locator to this ImageLoader's ComponentRegistry. All of Coil's first party decoders and fetchers are supported.
Return the separate segments of the Uri.path.
Enables adding all components (fetchers and decoders) that are supported by the service locator to this ImageLoader's ComponentRegistry. All of Coil's first party decoders and fetchers are supported.
If true, all components that are supported by the service locator will be added to this ImageLoader's ComponentRegistry.
If false, no components from the service locator will be added to the ImageLoader's ComponentRegistry.
If true, rewrite a GIF's frame delay to a default value if it is below a threshold. See https://github.com/coil-kt/coil/issues/540 for more info.
A Decoder that uses ImageDecoder to decode GIFs, animated WebPs, and animated HEIFs.
NOTE: Animated HEIF files are only supported on API 30 and above.
If true, rewrite a GIF's frame delay to a default value if it is below a threshold. See https://github.com/coil-kt/coil/issues/540 for more info.
An interface for making transformations to an animated image's pixel data.
Apply the transformation to the canvas.
If true, rewrite a GIF's frame delay to a default value if it is below a threshold. See https://github.com/coil-kt/coil/issues/540 for more info.
A Decoder that uses Movie to decode GIFs.
NOTE: Prefer using AnimatedImageDecoder on API 28 and above.
If true, rewrite a GIF's frame delay to a default value if it is below a threshold. See https://github.com/coil-kt/coil/issues/540 for more info.
Pass this to setRepeatCount to repeat infinitely.
Pass this to setRepeatCount to repeat infinitely.
Get the AnimatedTransformation.
Get the number of times the animation will repeat.
A Drawable that supports rendering Movies (i.e. GIFs).
NOTE: Prefer using AnimatedImageDecoder and AnimatedImageDrawable on API 28 and above.
Get the AnimatedTransformation.
Get the number of times the animation will repeat.
Set the AnimatedTransformation to apply when drawing.
Set the number of times to repeat the animation.
Set the AnimatedTransformation to apply when drawing.
Set the number of times to repeat the animation.
If the animation is already running, any iterations that have already occurred will count towards the new count.
NOTE: This method matches the behavior of AnimatedImageDrawable.setRepeatCount. i.e. setting repeatCount to 2 will result in the animation playing 3 times. Setting repeatCount to 0 will result in the animation playing once.
Default: REPEAT_INFINITE
Indicates that the AnimatedTransformation removed all transparent pixels in the image.
Indicates that the AnimatedTransformation added transparent pixels to the image.
Indicates that the AnimatedTransformation did not change the image's opacity.
Return this unless you add transparent pixels to the image or remove all transparent pixels in the image.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
Represents the opacity of an image's pixels after applying an AnimatedTransformation.
Indicates that the AnimatedTransformation did not change the image's opacity.
Indicates that the AnimatedTransformation added transparent pixels to the image.
Indicates that the AnimatedTransformation removed all transparent pixels in the image.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Returns an array containing the constants of this enum type, in the order they're declared.
This method may be used to iterate over the constants.
Set the AnimatedTransformation that will be applied to the result if it is an animated Drawable.
A Decoder that uses ImageDecoder to decode GIFs, animated WebPs, and animated HEIFs.
An interface for making transformations to an animated image's pixel data.
Represents the opacity of an image's pixels after applying an AnimatedTransformation.
Set the AnimatedTransformation that will be applied to the result if it is an animated Drawable.
Set the callback to be invoked at the end of the animation if the result is an animated Drawable.
Set the callback to be invoked at the start of the animation if the result is an animated Drawable.
Set the number of times to repeat the animation if the result is an animated Drawable.
Set the callback to be invoked at the end of the animation if the result is an animated Drawable.
Set the callback to be invoked at the start of the animation if the result is an animated Drawable.
Holds the response metadata for an image in the disk cache.
The default CacheStrategy, which always returns the disk cache response.
Create an output that will use cacheResponse as the image source.
Create an output that will execute networkRequest and use the response body as the image source.
Create an output that will execute networkRequest and use cacheResponse as the image source if the response code is 304 (not modified). Else, the network request's response body will be used as the image source.
Create an output that will use cacheResponse as the image source.
Create an output that will execute networkRequest and use the response body as the image source.
Create an output that will execute networkRequest and use cacheResponse as the image source if the response code is 304 (not modified). Else, the network request's response body will be used as the image source.
Determines whether to use a cached response from the disk cache and/or perform a new network request.
A naive ConnectivityChecker implementation that is always online.
A naive ConnectivityChecker implementation that is always online.
Determines if the device is able to access the internet.
An asynchronous HTTP client that executes NetworkRequests and returns NetworkResponses.
Parse the response's content-type
header.
"text/plain" is often used as a default/fallback MIME type. Attempt to guess a better MIME type from the file extension.
The URL to fetch.
The HTTP method.
The HTTP headers.
The HTTP request body.
Represents an HTTP request.
The URL to fetch.
The HTTP method.
The HTTP headers.
The HTTP request body.
The NetworkRequest that was executed to create this response.
The HTTP response code.
Timestamp of when the request was launched.
Timestamp of when the response was received.
The HTTP headers.
The HTTP response body.
The underlying response instance. If executed by OkHttp, this is okhttp3.Response
. If executed by Ktor, this is io.ktor.client.statement.HttpResponse
.
Represents an HTTP response.
The NetworkRequest that was executed to create this response.
The HTTP response code.
Timestamp of when the request was launched.
Timestamp of when the response was received.
The HTTP headers.
The HTTP response body.
The underlying response instance. If executed by OkHttp, this is okhttp3.Response
. If executed by Ktor, this is io.ktor.client.statement.HttpResponse
.
The NetworkRequest that was executed to create this response.
Set the HTTP request body for any network operations performed by this image request.
Set the HTTP request headers for any network operations performed by this image request.
Set the HTTP request method for any network operations performed by this image request.
Holds the response metadata for an image in the disk cache.
Determines whether to use a cached response from the disk cache and/or perform a new network request.
Determines if the device is able to access the internet.
Exception for an unexpected, non-2xx HTTP response.
An asynchronous HTTP client that executes NetworkRequests and returns NetworkResponses.
Represents a list of HTTP headers.
Represents an HTTP request.
Represents an HTTP response.
The default CacheStrategy, which always returns the disk cache response.
Set the HTTP request body for any network operations performed by this image request.
Set the HTTP request headers for any network operations performed by this image request.
Set the HTTP request method for any network operations performed by this image request.
If true, uses the SVG's view bounds as the intrinsic size for the SVG. If false, uses the SVG's width/height as the intrinsic size for the SVG.
If true, renders the SVG to a bitmap immediately after decoding. Else, the SVG will be rendered at draw time. Rendering at draw time is more memory efficient, but depending on the complexity of the SVG, can be slow.
A Decoder that decodes SVGs. Relies on external dependencies to parse and decode the SVGs (see Svg).
If true, uses the SVG's view bounds as the intrinsic size for the SVG. If false, uses the SVG's width/height as the intrinsic size for the SVG.
If true, renders the SVG to a bitmap immediately after decoding. Else, the SVG will be rendered at draw time. Rendering at draw time is more memory efficient, but depending on the complexity of the SVG, can be slow.
If true, renders the SVG to a bitmap immediately after decoding. Else, the SVG will be rendered at draw time. Rendering at draw time is more memory efficient, but depending on the complexity of the SVG, can be slow.
If true, uses the SVG's view bounds as the intrinsic size for the SVG. If false, uses the SVG's width/height as the intrinsic size for the SVG.
Specifies additional CSS rules that will be applied when rendering an SVG in addition to any rules specified in the SVG itself.
A Decoder that decodes SVGs. Relies on external dependencies to parse and decode the SVGs (see Svg).
Create a new FakeImageLoaderEngine that returns drawable for all requests.
Create a new FakeImageLoaderEngine that returns image for all requests.
Add an OptionalInterceptor.
Create a new FakeImageLoaderEngine instance.
Remove all OptionalInterceptors.
Set a default Image that will be returned if no OptionalInterceptors handle the request. If a default is not set, any requests not handled by an OptionalInterceptor will throw an exception.
Set the default Interceptor that will be called if no OptionalInterceptors handle the request. If a default is not set, any requests not handled by an OptionalInterceptor will throw an exception.
Add an OptionalInterceptor.
Create a new FakeImageLoaderEngine instance.
Remove all OptionalInterceptors.
Set a default Image that will be returned if no OptionalInterceptors handle the request. If a default is not set, any requests not handled by an OptionalInterceptor will throw an exception.
Set the default Interceptor that will be called if no OptionalInterceptors handle the request. If a default is not set, any requests not handled by an OptionalInterceptor will throw an exception.
Add an interceptor that will return Image if data is equal to an incoming ImageRequest's data.
Add an interceptor that will call interceptor if predicate returns true
.
Remove interceptor from the list of OptionalInterceptors.
Set a callback to modify an incoming ImageRequest before it's handled by the interceptors.
Add an interceptor that will return Image if data is equal to an incoming ImageRequest's data.
Add an interceptor that will return Image if predicate returns true
.
Add an interceptor that will call interceptor if predicate returns true
.
Remove interceptor from the list of OptionalInterceptors.
Set a callback to modify an incoming ImageRequest before it's handled by the interceptors.
By default, FakeImageLoaderEngine uses this callback to clear an ImageRequest's transition and setting this callback replaces that behaviour.
An Interceptor that can either:
Return an ImageResult so no subsequent interceptors are called.
Return null
to delegate to the next OptionalInterceptor in the list.
Optionally, call Interceptor.Chain.proceed to call through to the ImageLoader's real interceptor chain. Typically, this will map, fetch, and decode the data using the image loader's real image engine.
A callback to support modifying an ImageRequest before it's handled by the OptionalInterceptors.
An ImageLoader interceptor that intercepts all incoming requests before they're fetched and decoded by the image loader's real image engine. This class is useful for overriding an image loader's responses in tests:
val engine = FakeImageLoaderEngine.Builder()
.intercept("https://www.example.com/image.jpg", FakeImage())
.intercept({ it is String && it.endsWith("test.png") }, FakeImage())
.default(FakeImage(color = 0x0000FF))
.build()
val imageLoader = ImageLoader.Builder(context)
.components { add(engine) }
.build()
An Interceptor that can either:
A callback to support modifying an ImageRequest before it's handled by the OptionalInterceptors.
Returns a Flow that emits when a request starts.
Returns a Flow that emits when a request completes.
Create a new FakeImageLoaderEngine.Builder with the same configuration.
Create a new FakeImageLoaderEngine.Builder with the same configuration.
Returns a Flow that emits when a request starts.
Returns a Flow that emits when a request completes.
An ImageLoader interceptor that intercepts all incoming requests before they're fetched and decoded by the image loader's real image engine. This class is useful for overriding an image loader's responses in tests:
Create a new FakeImageLoaderEngine that returns drawable for all requests.
Create a new FakeImageLoaderEngine that returns image for all requests.
A Decoder that uses MediaMetadataRetriever to fetch and decode a frame from a video.
A Decoder that uses MediaMetadataRetriever to fetch and decode a frame from a video.
Set the frame index to extract from a video.
Set the time in microseconds of the frame to extract from a video.
Set the time in milliseconds of the frame to extract from a video.
Set the option for how to decode the video frame.
Set the time as a percentage of the total duration for the frame to extract from a video.
Set the frame index to extract from a video.
When both videoFrameIndex and other videoFrame-prefixed properties are set, videoFrameIndex will take precedence.
Set the time in microseconds of the frame to extract from a video.
When both videoFrameMicros (or videoFrameMillis) and videoFramePercent are set, videoFrameMicros (or videoFrameMillis) will take precedence.
Set the time in milliseconds of the frame to extract from a video.
When both videoFrameMicros (or videoFrameMillis) and videoFramePercent are set, videoFrameMicros (or videoFrameMillis) will take precedence.
Set the option for how to decode the video frame.
Must be one of OPTION_PREVIOUS_SYNC, OPTION_NEXT_SYNC, OPTION_CLOSEST_SYNC, OPTION_CLOSEST.
Set the time as a percentage of the total duration for the frame to extract from a video.
When both videoFrameMicros (or videoFrameMillis) and videoFramePercent are set, videoFrameMicros (or videoFrameMillis) will take precedence.
A factory that creates the new singleton ImageLoader.
To configure how the singleton ImageLoader is created either:
Implement SingletonImageLoader.Factory on your Android Application
class.
Or call SingletonImageLoader.setSafe with your SingletonImageLoader.Factory.
Return a new ImageLoader.
Return a new ImageLoader.
Get the singleton ImageLoader.
A class that holds the singleton ImageLoader instance.
A factory that creates the new singleton ImageLoader.
Get the singleton ImageLoader.
Clear the ImageLoader or Factory held by this class.
Set the Factory that will be used to lazily create the singleton ImageLoader.
Set the singleton ImageLoader and overwrite any previously set value.
Set the Factory that will be used to lazily create the singleton ImageLoader and overwrite any previously set value.
Clear the ImageLoader or Factory held by this class.
Set the Factory that will be used to lazily create the singleton ImageLoader.
This function is similar to setUnsafe except:
If an ImageLoader has already been created it will not be replaced with factory.
If the singleton ImageLoader has already been created, an error will be thrown as it indicates setSafe is being called too late and after get has already been called.
It's safe to call setSafe multiple times.
The factory is guaranteed to be invoked at most once.
Set the singleton ImageLoader and overwrite any previously set value.
Set the Factory that will be used to lazily create the singleton ImageLoader and overwrite any previously set value.
The factory is guaranteed to be invoked at most once.
Get the singleton ImageLoader.
A class that holds the singleton ImageLoader instance.
Get the singleton ImageLoader.
Get the ImageResult of the most recently executed image request that's attached to this view.
Load the image referenced by data and set it on this ImageView.
Example:
imageView.load("https://example.com/image.jpg") {
crossfade(true)
transformations(CircleCropTransformation())
}
The data to load.
The ImageLoader that will be used to enqueue the ImageRequest. By default, the singleton ImageLoader will be used.
An optional lambda to configure the ImageRequest.
Get the ImageResult of the most recently executed image request that's attached to this view.
ImageLoader.Builder.networkObserverEnabled
with a ConnectivityChecker
interface for NetworkFetcher
.ConnectivityChecker.ONLINE
to the constructor for KtorNetworkFetcherFactory
/OkHttpNetworkFetcherFactory
.Res.getUri
:maxBitmapSize
property to ImageLoader
and ImageRequest
.Size.ORIGINAL
and causing an out of memory exception.ExifOrientationPolicy
to be an interface to support custom policies.Uri
handling of Windows file paths.@ExperimentalCoilApi
from the Image
APIs.io.coil-kt.coil3:coil-network-ktor
artifact to io.coil-kt.coil3:coil-network-ktor2
which depends on Ktor 2.x. Additionally, introduce io.coil-kt.coil3:coil-network-ktor3
which depends on Ktor 3.x. wasmJs
support is only available in Ktor 3.x.AsyncImagePainter.restart()
to manually restart an image request.@ExperimentalCoilApi
from NetworkClient
and related classes.ImageRequest
to avoid unnecessary Extras
and Map
allocations.ImageLoader.execute
, AsyncImage
, SubcomposeAsyncImage
, and rememberAsyncImagePainter
. (#2205)ImageRequest
and ImageLoader
dispatcher
methods to coroutineContext
. For instance, ImageRequest.Builder.dispatcher
is now ImageRequest.Builder.coroutineContext
. This was renamed as the method now accepts any CoroutineContext
and no longer requires a Dispatcher
.IllegalStateException: Reading a state that was created after the snapshot was taken or in a snapshot that has not yet been applied
which could occur due to a race condition.Dispatchers.Main.immediate
. As a result you should re-add a dependency on kotlinx-coroutines-swing
on JVM. If it's not imported then ImageRequest
s won't be dispatched immediately and will have one frame of delay before setting the ImageRequest.placeholder
or resolving from the memory cache.AsyncImagePainter
no longer waits for onDraw
by default and instead uses Size.ORIGINAL
.onDraw
, set DrawScopeSizeResolver
as your ImageRequest.sizeResolver
.Image
API. Notably, asCoilImage
has been renamed to asImage
.AsyncImagePainter.state
has been changed to StateFlow<AsyncImagePainter.State>
. Use collectAsState
to observe its value. This improves performance.AsyncImagePainter.imageLoader
and AsyncImagePainter.request
have been combined into StateFlow<AsyncImagePainter.Inputs>
. Use collectAsState
to observe its value. This improves performance.android.resource://example.package.name/drawable/image
URIs as it prevents resource shrinking optimizations.ResourceUriMapper
in your component registry.AsyncImagePreviewHandler
to support controlling AsyncImagePainter
's preview rendering behavior.LocalAsyncImagePreviewHandler
to override the preview behavior.coil-compose
improvements, AsyncImagePainter
now attempts to execute execute the ImageRequest
by default instead of defaulting to displaying ImageRequest.placeholder
. Requests that use the network or files are expected to fail in the preview environment, however Android resources should work.CoroutineContext
to any CoroutineDispatcher
methods. (#2241).Dispatchers.Main.immediate
in Compose. As a side-effect, kotlinx-coroutines-swing
no longer needs to be imported on JVM.async
and create a disposable in Compose to improve performance (thanks @mlykotom!). (#2205)ImageLoader
extras to Options
. (#2223)crossfade(false)
not working on non-Android targets.SvgDecoder
on non-Android targets to render to a bitmap instead of render the image at draw-time. This improves performance.SvgDecoder(renderToBitmap)
.ScaleDrawable
from coil-gif
to coil-core
.wasmJs
target.DrawablePainter
and DrawableImage
to support drawing Image
s that aren't backed by a Bitmap
on non-Android platforms.Image
APIs are experimental and likely to change between alpha releases.ContentPainterModifier
to implement Modifier.Node
.ImageLoader.Builder.placeholder/error/fallback
not being used by ImageRequest
.rememberAsyncImagePainter
, AsyncImage
, and SubcomposeAsyncImage
restartable and skippable. This improves performance by avoiding recomposition unless one of the composable's arguments changes.modelEqualityDelegate
argument to rememberAsyncImagePainter
, AsyncImage
, and SubcomposeAsyncImage
to control whether the model
will trigger a recomposition.ContentPainterModifier
to implement Modifier.Node
.rememberAsyncImagePainter
, AsyncImage
, and SubcomposeAsyncImage
if ImageRequest.listener
or ImageRequest.target
change.AsyncImagePainter
.androidx.collection
to 1.4.0.androidx.lifecycle
to 2.7.0.Lazy
from OkHttpNetworkFetcherFactory
and KtorNetworkFetcherFactory
's public API.Call.Factory
instead of OkHttpClient
in OkHttpNetworkFetcherFactory
.NetworkResponseBody
to wrap a ByteString
.coil-network
has been renamed to coil-network-ktor
. Additionally, there is a new coil-network-okhttp
artifact that depends on OkHttp and doesn't require specifying a Ktor engine.Fetcher.Factory
manually using KtorNetworkFetcherFactory
or OkHttpNetworkFetcherFactory
.NSUrl
on Apple platforms.clipToBounds
parameter to AsyncImage
.coil-gif
, coil-network
, coil-svg
, and coil-video
's packages have been updated so all their classes are part of coil.gif
, coil.network
, coil.svg
, and coil.video
respectively. This helps avoid class name conflicts with other artifacts.ImageDecoderDecoder
has been renamed to AnimatedImageDecoder
.coil-gif
, coil-network
, coil-svg
, and coil-video
's components are now automatically added to each ImageLoader
's ComponentRegistry
.3.0.0-alpha01
you do not need to manually add NetworkFetcher.Factory()
to your ComponentRegistry
. Simply importing io.coil-kt.coil3:coil-network:[version]
and a Ktor engine is enough to load network images.ComponentRegistry
manually. Any manually added components take precedence over components that are added automatically.ImageLoader.Builder.serviceLoaderEnabled(false)
.coil-svg
on all platforms. It's backed by AndroidSVG on Android and SVGDOM on non-Android platforms.ImageDecoder
API internally, which has performance benefits when decoding directly from a file, resource, or content URI.coil3.Uri
parsing fixes.io.coil-kt.coil3
and its imports were updated to coil3
. This allows Coil 3 to run side by side with Coil 2 without binary compatibility issues. For example, io.coil-kt:coil:[version]
is now io.coil-kt.coil3:coil:[version]
.coil-base
and coil-compose-base
artifacts were renamed to coil-core
and coil-compose-core
respectively to align with the naming conventions used by Coroutines, Ktor, and AndroidX.MediaDataSourceFetcher.Factory
to support decoding MediaDataSource
implementations in coil-video
. (#1795)SHIFT6m
device to the hardware bitmap blocklist. (#1812)304 Not Modified
when cached headers include non-ASCII characters. (#1839)FakeImageEngine
not updating the interceptor chain's request. (#1905)accompanist-drawablepainter
to 0.32.0.androidx.annotation
to 1.7.0.androidx.compose.foundation
to 1.5.4.androidx.core
to 1.12.0.androidx.exifinterface:exifinterface
to 1.3.6.androidx.lifecycle
to 2.6.2.com.squareup.okhttp3
to 4.12.0.com.squareup.okio
to 3.6.0.DiskCache
get
/edit
to openSnapshot
/openEditor
.ColorDrawable
to ColorPainter
in AsyncImagePainter
.AsyncImage
overloads with @NonRestartableComposable
.Context.cacheDir
lazily in ImageSource
.coil-bom
.ARGB_8888
if hardware bitmaps are disabled.accompanist-drawablepainter
to 0.30.1.androidx.compose.foundation
to 1.4.3.androidx.profileinstaller:profileinstaller
to 1.3.1.com.squareup.okhttp3
to 4.11.0.coil-test
artifact, which includes FakeImageLoaderEngine
. This class is useful for hardcoding image loader responses to ensure consistent and synchronous (from the main thread) responses in tests. See here for more info.coil-base
(child module of coil
) and coil-compose-base
(child module of coil-compose
).file://
URIs with encoded data. #1601DiskCache
now properly computes its maximum size if passed a directory that does not exist. #1620Coil.reset
public API. #1506accompanist-drawablepainter
to 0.30.0.androidx.annotation
to 1.6.0.androidx.appcompat:appcompat-resources
to 1.6.1.androidx.compose.foundation
to 1.4.0.androidx.core
to 1.9.0.androidx.exifinterface:exifinterface
to 1.3.6.androidx.lifecycle
to 2.6.1.okio
to 3.3.0.VideoFrameDecoder
on API 30+ to avoid banding. #1487#
in FileUriMapper
. #1466androidx.annotation
to 1.5.0.RoundedCornersTransformation
now properly scales the input
bitmap.kotlin-parcelize
plugin.androidx.appcompat:appcompat-resources
to 1.4.2 to work around #1423.ImageRequest.videoFramePercent
to coil-video
to support specifying the video frame as a percent of the video's duration.ExifOrientationPolicy
to configure how BitmapFactoryDecoder
treats EXIF orientation data.RoundedCornersTransformation
if passed a size with an undefined dimension.accompanist-drawablepainter
to 0.25.1.androidx.annotation
to 1.4.0.androidx.appcompat:appcompat-resources
to 1.5.0.androidx.core
to 1.8.0.ByteArray
s. (#1202)ImageRequest.Builder.css
. (#1210)GenericViewTarget
's private methods to protected. (#1273)Coil 2.0.0 is a major iteration of the library and includes breaking changes. Check out the upgrade guide for how to upgrade.
AsyncImage
in coil-compose
. Check out the documentation for more info.// Display an image from the network.
+AsyncImage(
+ model = "https://example.com/image.jpg",
+ contentDescription = null,
+)
+
+// Display an image from the network with a placeholder, circle crop, and crossfade animation.
+AsyncImage(
+ model = ImageRequest.Builder(LocalContext.current)
+ .data("https://example.com/image.jpg")
+ .crossfade(true)
+ .build(),
+ placeholder = painterResource(R.drawable.placeholder),
+ contentDescription = stringResource(R.string.description),
+ contentScale = ContentScale.Crop,
+ modifier = Modifier.clip(CircleShape)
+)
+
DiskCache
API.ImageLoader.Builder.diskCache
and DiskCache.Builder
to configure the disk cache.Cache
with Coil 2.0. See here for more info.Cache-Control
and other cache headers are still supported - except Vary
headers, as the cache only checks that the URLs match. Additionally, only responses with a response code in the range [200..300) are cached.ImageRequest
's default Scale
is now Scale.FIT
.ImageRequest.scale
consistent with other classes that have a default Scale
.ImageViewTarget
still have their Scale
auto-detected.Mapper
, Fetcher
, and Decoder
have been refactored to be more flexible.Fetcher.key
has been replaced with a new Keyer
interface. Keyer
creates the cache key from the input data.ImageSource
, which allows Decoder
s to read File
s directly using Okio's file system API.rememberImagePainter
and ImagePainter
have been renamed to rememberAsyncImagePainter
and AsyncImagePainter
respectively.LocalImageLoader
. Check out the deprecation message for more info.NullPointerException
immediately. Kotlin's compile-time null safety guards against this happening.Size
is now composed of two Dimension
values for its width and height. Dimension
can either be a positive pixel value or Dimension.Undefined
. See here for more info.BitmapPool
and PoolableViewTarget
have been removed from the library.VideoFrameFileFetcher
and VideoFrameUriFetcher
have been removed from the library. Use VideoFrameDecoder
instead, which supports all data sources.BlurTransformation
and GrayscaleTransformation
are removed from the library. If you use them, you can copy their code into your project.Transition.transition
to be a non-suspending function as it's no longer needed to suspend the transition until it completes.bitmapFactoryMaxParallelism
, which restricts the maximum number of in-progress BitmapFactory
operations. This value is 4 by default, which improves UI performance.interceptorDispatcher
, fetcherDispatcher
, decoderDispatcher
, and transformationDispatcher
.GenericViewTarget
, which handles common ViewTarget
logic.ByteBuffer
to the default supported data types.Disposable
has been refactored and exposes the underlying ImageRequest
's job.MemoryCache
API.ImageRequest.error
is now set on the Target
if ImageRequest.fallback
is null.Transformation.key
is replaced with Transformation.cacheKey
.Changes from 2.0.0-rc03
: - Convert Dimension.Original
to be Dimension.Undefined
. - This changes the semantics of the non-pixel dimension slightly to fix some edge cases (example) in the size system. - Load images with Size.ORIGINAL
if ContentScale is None. - Fix applying ImageView.load
builder argument first instead of last. - Fix not combining HTTP headers if response is not modified.
ScaleResolver
interface.Size
constructors to functions.Dimension.Pixels
's toString
to only be its pixel value.SystemCallbacks.onTrimMemory
.ImageRequest
's default size to be the size of the current display instead of Size.ORIGINAL
.DiskCache.Builder
being marked as experimental. Only DiskCache
's methods are experimental.ImageView
with one dimension as WRAP_CONTENT
would load the image at its original size instead of fitting it into the bounded dimension.MemoryCache.Key
, MemoryCache.Value
, and Parameters.Entry
.Significant changes since 1.4.0
:
rememberImagePainter
has been renamed to rememberAsyncImagePainter
.AsyncImage
and SubcomposeAsyncImage
. Check out the documentation for more info.LocalImageLoader
. Check out the deprecation message for more info.ImageLoader.Builder.diskCache
and DiskCache.Builder
to configure the disk cache.Cache
with Coil 2.0 as the cache can be corrupted if a thread is interrupted while writing to it.Cache-Control
and other cache headers are still supported - except Vary
headers, as the cache only checks that the URLs match. Additionally, only responses with a response code in the range [200..300) are cached.ImageRequest
's default Scale
is now Scale.FIT
.ImageRequest.scale
consistent with other classes that have a default Scale
.ImageViewTarget
still have their Scale
auto-detected.ImageRequest
's default size is now Size.ORIGINAL
.Mapper
, Fetcher
, and Decoder
have been refactored to be more flexible.Fetcher.key
has been replaced with a new Keyer
interface. Keyer
creates the cache key from the input data.ImageSource
, which allows Decoder
s to read File
s directly using Okio's file system API.NullPointerException
immediately. Kotlin's compile-time null safety guards against this happening.Size
is now composed of two Dimension
values for its width and height. Dimension
can either be a positive pixel value or Dimension.Original
.BitmapPool
and PoolableViewTarget
have been removed from the library.VideoFrameFileFetcher
and VideoFrameUriFetcher
are removed from the library. Use VideoFrameDecoder
instead, which supports all data sources.BlurTransformation
and GrayscaleTransformation
are removed from the library. If you use them, you can copy their code into your project.Transition.transition
to be a non-suspending function as it's no longer needed to suspend the transition until it completes.bitmapFactoryMaxParallelism
, which restricts the maximum number of in-progress BitmapFactory
operations. This value is 4 by default, which improves UI performance.interceptorDispatcher
, fetcherDispatcher
, decoderDispatcher
, and transformationDispatcher
.GenericViewTarget
, which handles common ViewTarget
logic.ByteBuffer
to the default supported data types.Disposable
has been refactored and exposes the underlying ImageRequest
's job.MemoryCache
API.ImageRequest.error
is now set on the Target
if ImageRequest.fallback
is null.Transformation.key
is replaced with Transformation.cacheKey
.Changes since 2.0.0-alpha09
:
-Xjvm-default=all
compiler flag.DecodeUtils.isSvg
returning false if there is a new line character after the <svg
tag.LocalImageLoader.provides
deprecation message clearer.accompanist-drawablepainter
to 0.23.1.AsyncImage
creating invalid constraints. (#1134)ContentScale
argument to AsyncImagePainter
. (#1144)Image
to ensure that the image is loaded at the correct size.ScaleResolver
to support lazily resolving the Scale
for an ImageRequest
. (#1134)ImageRequest.scale
should be replaced by ImageRequest.scaleResolver.scale()
.accompanist-drawablepainter
to 0.23.0.androidx.lifecycle
to 2.4.1.DiskCache
and ImageSource
to use to Okio's FileSystem
API. (#1115)AsyncImage
performance and split AsyncImage
into AsyncImage
and SubcomposeAsyncImage
. (#1048)SubcomposeAsyncImage
provides loading
/success
/error
/content
slot APIs and uses subcomposition which has worse performance.AsyncImage
provides placeholder
/error
/fallback
arguments to overwrite the Painter
that's drawn when loading or if the request is unsuccessful. AsyncImage
does not use subcomposition and has much better performance than SubcomposeAsyncImage
.AsyncImagePainter.State
argument from SubcomposeAsyncImage.content
. Use painter.state
if needed.onLoading
/onSuccess
/onError
callbacks to both AsyncImage
and SubcomposeAsyncImage
.LocalImageLoader
. (#1101)ImageRequest.tags
. (#1066)isGif
, isWebP
, isAnimatedWebP
, isHeif
, and isAnimatedHeif
in DecodeUtils
into coil-gif. Add isSvg
to coil-svg. (#1117)FetchResult
and DecodeResult
to be non-data classes. (#1114)DiskCache.Builder
context argument. (#1099)ImageDecoder
in ImageDecoderDecoder
. (#1109)accompanist-drawablepainter
to 0.22.1-rc.androidx.appcompat:appcompat-resources
to 1.4.1.ImageSource.Metadata
to support decoding from assets, resources, and content URIs without buffering or temporary files. (#1060)AsyncImage
has positive constraints. (#1028)DefaultContent
for AsyncImage
if loading
, success
, and error
are all set. (#1026)LruCache
instead of the platform LruCache
. (#1047)accompanist-drawablepainter
to 0.22.0-rc.androidx.collection
to 1.2.0.Size
to support using the image's original size for either dimension.Size
is now composed of two Dimension
values for its width and height. Dimension
can either be a positive pixel value or Dimension.Original
.wrap_content
, Constraints.Infinity
) when one dimension is a fixed pixel value.AsyncImage
.SuccessResult.memoryCacheKey
should always be null
if imageLoader.memoryCache
is null.ImageLoader
, SizeResolver
, and ViewSizeResolver
constructor-like invoke
functions to top level functions.CrossfadeDrawable
start and end drawables public API.ImageLoader
placeholder/error/fallback drawables.SuccessResult
's constructor.androidx.collection
instead of androidx.collection-ktx
.AsyncImage
to coil-compose
.AsyncImage
is a composable that executes an ImageRequest
asynchronously and renders the result.AsyncImage
is intended to replace rememberImagePainter
for most use cases.Image
and supports the same arguments: Alignment
, ContentScale
, alpha
, ColorFilter
, and FilterQuality
.AsyncImagePainter
state using the content
, loading
, success
, and error
arguments.rememberImagePainter
has with resolving image size and scale.// Only draw the image.
+AsyncImage(
+ model = "https://example.com/image.jpg",
+ contentDescription = null, // Avoid `null` and set this to a localized string if possible.
+)
+
+// Draw the image with a circle crop, crossfade, and overwrite the `loading` state.
+AsyncImage(
+ model = ImageRequest.Builder(LocalContext.current)
+ .data("https://example.com/image.jpg")
+ .crossfade(true)
+ .build(),
+ contentDescription = null,
+ modifier = Modifier
+ .clip(CircleShape),
+ loading = {
+ CircularProgressIndicator()
+ },
+ contentScale = ContentScale.Crop
+)
+
+// Draw the image with a circle crop, crossfade, and overwrite all states.
+AsyncImage(
+ model = ImageRequest.Builder(LocalContext.current)
+ .data("https://example.com/image.jpg")
+ .crossfade(true)
+ .build(),
+ contentDescription = null,
+ modifier = Modifier
+ .clip(CircleShape),
+ contentScale = ContentScale.Crop
+) { state ->
+ if (state is AsyncImagePainter.State.Loading) {
+ CircularProgressIndicator()
+ } else {
+ AsyncImageContent() // Draws the image.
+ }
+}
+
ImagePainter
to AsyncImagePainter
and rememberImagePainter
to rememberAsyncImagePainter
.ExecuteCallback
is no longer supported. To have the AsyncImagePainter
skip waiting for onDraw
to be called, set ImageRequest.size(OriginalSize)
(or any size) instead.FilterQuality
argument to rememberAsyncImagePainter
.DiskCache
and add DiskCache.Builder.cleanupDispatcher
.ImageLoader.Builder.placeholder
.LocalImageLoader.current
with @ReadOnlyComposable
to generate more efficient code.compose.foundation
instead of compose.ui
.androidx.appcompat-resources
to 1.4.0.context.resources
to load resources for current package. (#968)clear
-> dispose
replacement expression. (#970)accompanist-drawablepainter
to 0.20.2.androidx.annotation
to 1.3.0.androidx.core
to 1.7.0.androidx.lifecycle
to 2.4.0.lifecycle-common-java8
as it's been merged into lifecycle-common
.coil-bom
artifact which includes a bill of materials.coil-bom
allows you to depend on other Coil artifacts without specifying a version.ExecuteCallback.Immediate
.Coil 2.0.0 is the next major iteration of the library and has new features, performance improvements, API improvements, and various bug fixes. This release may be binary/source incompatible with future alpha releases until the stable release of 2.0.0.
-Xjvm-default=all
.-Xjvm-default=all
or -Xjvm-default=all-compatibility
to your build file as well. See here for how to do this.ImageSource
s backed by File
s. This avoids unnecessary copying when an Android API requires a File
to decode (e.g. MediaMetadataRetriever
).ImageLoader.Builder.diskCache
and DiskCache.Builder
to configure the disk cache.Cache
with Coil 2.0 as it can be corrupted if it's interrupted while writing to it.Cache-Control
and other cache headers are still supported - except Vary
headers, as the cache only checks that the URLs match. Additionally, only responses with a response code in the range [200..300) are cached.ImageLoader.Builder.respectCacheHeaders
.ImageRequest
's default Scale
is now Scale.FIT
ImageRequest.scale
consistent with other classes that have a default Scale
.ImageViewTarget
still have their scale autodetected.Mapper
, Fetcher
, and Decoder
have been refactored to be more flexible.Fetcher.key
has been replaced with a new Keyer
interface. Keyer
creates the cache key from the input data.ImageSource
, which allows Decoder
s to decode File
s directly.BitmapPool
and PoolableViewTarget
have been removed from the library. Bitmap pooling was removed because:Drawable
in more places (e.g. Listener
, Disposable
). Additionally, this means Coil doesn't have to clear ImageView
s, which has can cause issues.MemoryCache
has been refactored to be more flexible.NullPointerException
immediately. If you use Kotlin, there is essentially no change.VideoFrameFileFetcher
and VideoFrameUriFetcher
are removed from the library. Use VideoFrameDecoder
instead, which supports all data sources.bitmapFactoryMaxParallelism
, which restricts the maximum number of in-progress BitmapFactory
operations. This value is 4 by default, which improves UI performance.interceptorDispatcher
, fetcherDispatcher
, decoderDispatcher
, and transformationDispatcher
.Disposable
has been refactored and exposes the underlying ImageRequest
's job.Transition.transition
to be a non-suspending function as it's no longer needed to suspend the transition until it completes.GenericViewTarget
, which handles common ViewTarget
logic.BlurTransformation
and GrayscaleTransformation
are removed from the library.ImageRequest.error
is now set on the Target
if ImageRequest.fallback
is null.Transformation.key
is replaced with Transformation.cacheKey
.ImageRequest.Listener
returns SuccessResult
/ErrorResult
in onSuccess
and onError
respectively.ByteBuffer
s to the default supported data types.toString
implementations from several classes.ImageResult
to ImagePainter.State.Success
and ImagePainter.State.Error
. (#887)ImagePainter.State.Success
and ImagePainter.State.Error
, however these APIs are marked as experimental.CrossfadeTransition
if View.isShown
is true
. Previously it would only check View.isVisible
. (#898)ComponentRegistry
methods public. (#925)accompanist-drawablepainter
and remove Coil's custom DrawablePainter
implementation. (#845)ImagePainter.ExecuteCallback
to stable API. (#927)coil-compose
now depends on compose.ui
instead of compose.foundation
.compose.ui
is a smaller dependency as it's a subset of compose.foundation
.androidx.exifinterface:exifinterface
to 1.3.3.1.0.0
. Huge congrats to the Compose team on the stable release!androidx.appcompat:appcompat-resources
to 1.3.1.allowConversionToBitmap
to enable/disable the automatic bitmap conversion for Transformation
s. (#775)enforceMinimumFrameDelay
to ImageDecoderDecoder
and GifDecoder
to enable rewriting a GIF's frame delay if it's below a threshold. (#783)ImageLoader
's internal network observer. (#741)BitmapFactoryDecoder
. (#776)androidx.core:core-ktx
to 1.6.0.ImageLoader.Builder.fallback
setting the error
drawable instead of the fallback
drawable.ResourceUriFetcher
. (#770)androidx.appcompat:appcompat-resources
to 1.3.0.androidx.core:core-ktx
to 1.5.0.VideoFrameUriFetcher
attempting to handle http/https URIs. (#734SvgDecoder
. (#688)SvgDecoder
used an SVG's width
/height
elements to determine its aspect ratio, however this doesn't correctly follow the SVG specification.useViewBoundsAsIntrinsicSize = false
when constructing your SvgDecoder
.VideoFrameDecoder
to support decoding video frames from any source. (#689)ImageLoader.newBuilder()
. (#653)ImageLoader
instances.AnimatedTransformation
. (#659)EmptyBitmapPool
implementation if bitmap pooling is disabled. (#638)BitmapPool
implementation.MovieDrawable.getOpacity
would incorrectly return transparent. (#682)androidx.lifecycle:lifecycle-common-java8
to 2.3.1.ViewSizeResolver.size
could throw an IllegalStateException
due to resuming a coroutine more than once.HttpFetcher
blocking forever if called from the main thread.ImageRequest.dispatcher(Dispatchers.Main.immediate)
will fail with a NetworkOnMainThreadException
unless ImageRequest.networkCachePolicy
is set to CachePolicy.DISABLED
or CachePolicy.WRITE_ONLY
.VideoFrameFetcher
if the video has rotation metadata.androidx.exifinterface:exifinterface
(1.3.2).CENTER
and MATRIX
ImageView
scale types to resolve to OriginalSize
. (#587)ImageView.setImageResource
/ImageView.setImageURI
. To revert to the old behaviour set a ViewSizeResolver
when constructing your request.ViewSizeResolver
if the view's layout param is WRAP_CONTENT
. (#562)CrossfadeDrawable
. (#585)EventListener.Factory
a functional interface. (#575)EventListener
. (#574)String
overload for ImageRequest.Builder.placeholderMemoryCacheKey
.@JvmOverloads
to the ViewSizeResolver
constructor.CrossfadeDrawable
. (#572)kotlin-parcelize
plugin.Changes since 0.13.0
: - Add Context.imageLoader
extension function. (#534) - Add ImageLoader.executeBlocking
extension function. (#537) - Don't shutdown previous singleton image loader if replaced. (#533)
Changes since 1.0.0-rc3
: - Fix: Guard against missing/invalid ActivityManager. (#541) - Fix: Allow OkHttp to cache unsuccessful responses. (#551) - Update Kotlin to 1.4.10. - Update Okio to 2.9.0. - Update androidx.exifinterface:exifinterface
to 1.3.1.
-Xjvm-default=all
compiler flag due to instability.Context.imageLoader
extension function. (#534)ImageLoader.executeBlocking
extension function. (#537)androidx.exifinterface:exifinterface
-> 1.3.0stdlib
instead of stdlib-jdk8
.0.11.0
and below where the memory cache would be checked synchronously on the main thread.0.12.0
where the memory cache is checked on ImageRequest.dispatcher
, set ImageLoader.Builder.launchInterceptorChainOnMainThread(false)
.launchInterceptorChainOnMainThread
for more information.ViewTarget
in a detached fragment. (#518)ImageRequest.context
to load resource URIs. (#517)blockCountLong
and blockSizeLong
on API 18.ImageLoaderFactory
a fun interface.ImageLoader.Builder.addLastModifiedToFileCacheKey
which allows you to enable/disable adding the last modified timestamp to the memory cache key for an image loaded from a File
.-Xjvm-default=all
.-Xjvm-default=all
in your build file.LoadRequest
and GetRequest
have been replaced with ImageRequest
:ImageLoader.execute(LoadRequest)
-> ImageLoader.enqueue(ImageRequest)
ImageLoader.execute(GetRequest)
-> ImageLoader.execute(ImageRequest)
ImageRequest
implements equals
/hashCode
.coil.request.RequestResult
-> coil.request.ImageResult
coil.request.RequestDisposable
-> coil.request.Disposable
coil.bitmappool.BitmapPool
-> coil.bitmap.BitmapPool
coil.DefaultRequestOptions
-> coil.request.DefaultRequestOptions
SparseIntArraySet
has been removed from the public API.TransitionTarget
no longer implements ViewTarget
.ImageRequest.Listener.onSuccess
's signature has changed to return an ImageResult.Metadata
instead of just a DataSource
.LoadRequest.aliasKeys
. This API is better handled with direct read/write access to the memory cache.Interceptor
s on a background dispatcher.Mappers
are now executed on a background dispatcher. As a side effect, automatic bitmap sampling is no longer automatically supported. To achieve the same effect, use the MemoryCache.Key
of a previous request as the placeholderMemoryCacheKey
of the subsequent request. See here for an example.placeholderMemoryCacheKey
API offers more freedom as you can "link" two image requests with different data (e.g. different URLs for small/large images).ImageView
extension functions have been moved from the coil.api
package to the coil
package.import coil.api.load
-> import coil.load
. Unfortunately, it's not possible to use Kotlin's ReplaceWith
functionality to replace imports.MeasuredMapper
has been deprecated in favour of the new Interceptor
interface. See here for an example of how to convert a MeasuredMapper
into an Interceptor
.Interceptor
is a much less restrictive API that allows for a wider range of custom logic.ImageRequest.data
is now not null. If you create an ImageRequest
without setting its data it will return NullRequestData
as its data.ImageLoader
's MemoryCache
. See the docs for more information.Interceptor
s. See the docs for more information. Coil's Interceptor
design is heavily inspired by OkHttp's!ImageLoader.Builder.bitmapPoolingEnabled
.Bitmap.recycle
).androidx.appcompat:appcompat-resources
-> 1.2.0androidx.core:core-ktx
-> 1.3.1ContentProvider
so it doesn't run any code at app startup.SparseIntArraySet.size
to a val. (#380)Parameters.count()
to an extension function. (#403)BitmapPool.maxSize
an Int. (#404)ImageLoader.shutdown()
optional (similar to OkHttpClient
). (#385)ImageLoaderBuilder.availableMemoryPercentage(0.25)
when creating your ImageLoader
.SparseIntArraySet
.This version deprecates most of the DSL API in favour of using the builders directly. Here's what the change looks like:
// 0.9.5 (old)
+val imageLoader = ImageLoader(context) {
+ bitmapPoolPercentage(0.5)
+ crossfade(true)
+}
+
+val disposable = imageLoader.load(context, "https://example.com/image.jpg") {
+ target(imageView)
+}
+
+val drawable = imageLoader.get("https://example.com/image.jpg") {
+ size(512, 512)
+}
+
+// 0.10.0 (new)
+val imageLoader = ImageLoader.Builder(context)
+ .bitmapPoolPercentage(0.5)
+ .crossfade(true)
+ .build()
+
+val request = LoadRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .target(imageView)
+ .build()
+val disposable = imageLoader.execute(request)
+
+val request = GetRequest.Builder(context)
+ .data("https://example.com/image.jpg")
+ .size(512, 512)
+ .build()
+val drawable = imageLoader.execute(request).drawable
+
io.coil-kt:coil
artifact, you can call Coil.execute(request)
to execute the request with the singleton ImageLoader
.ImageLoader
s now have a weak reference memory cache that tracks weak references to images once they're evicted from the strong reference memory cache.
ImageLoader
's memory cache if there's still a strong reference to it.ImageLoaderBuilder.trackWeakReferences
.Add a new artifact, io.coil-kt:coil-video
, to decode specific frames from a video file. Read more here.
Add a new EventListener API for tracking metrics.
Add ImageLoaderFactory which can be implemented by your Application
to simplify singleton initialization.
Coil
and ImageLoader
extension functions. (#322)RequestResult
type from ImageLoader.execute(GetRequest)
. (#349)ExperimentalCoil
to ExperimentalCoilApi
. Migrate from @Experimental
to @RequiresOptIn
. (#306)CoilLogger
with Logger
interface. (#316)MovieDrawable
's constructor params. (#272)Request.Listener
's methods now receive the full Request
object instead of just its data.GetRequestBuilder
now requires a Context
in its constructor.Request
are now nullable.Request.Listener.onStart()
timing to be called immediately after Target.onStart()
. (#348)WeakMemoryCache
implementation. (#295)coil-video
to support decoding video frames. (#122)EventListener
. (#314)ImageLoaderFactory
. (#311)CachePolicy
. (#307)Bitmap.Config
. (#342)ImageLoader.invalidate(key)
to clear a single memory cache item (#55)error
and fallback
drawables for get requests.ImageDecoderDecoder
crash work-around on Android 11 and above. (#298)ImageView
has a matching SizeResolver
. (#344)CoilContentProvider
. (#293)ImageLoader
methods with @MainThread
.LifecycleCoroutineDispatcher
if the lifecycle is currently started. (#356)OriginalSize.toString()
.androidx.exifinterface:exifinterface
-> 1.2.0androidx.core:core-ktx
-> 1.2.0ARGB_8888
bitmap, it would be possible to have a RGBA_F16
bitmap returned to you from the memory cache. Now, the cached config and the requested config must be equal.scale
and durationMillis
public in CrossfadeDrawable
and CrossfadeTransition
.ScaleDrawable
to ensure it is centered.HttpUrl.get()
to background thread.androidx.lifecycle:lifecycle-common-java8
-> 2.2.0BitmapPool.trimMemory
public.LoadRequestBuilder.crossfade(false)
.Transformation.transform
now includes a Size
parameter. This is to support transformations that change the size of the output Bitmap
based on the size of the Target
. Requests with transformations are now also exempt from image sampling.Transformation
s are now applied to any type of Drawable
. Before, Transformation
s would be skipped if the input Drawable
was not a BitmapDrawable
. Now, Drawable
s are rendered to a Bitmap
before applying the Transformation
s.null
data to ImageLoader.load
is now treated as an error and calls Target.onError
and Request.Listener.onError
with a NullRequestDataException
. This change was made to support setting a fallback
drawable if data is null
. Previously the request was silently ignored.RequestDisposable.isDisposed
is now a val
.RequestDisposable.await
to support suspending while a LoadRequest
is in progress.fallback
drawable when request data is null.Precision
. This makes the size of the output Drawable
exact while enabling scaling optimizations for targets that support scaling (e.g. ImageViewTarget
). See its documentation for more information.RequestBuilder.aliasKeys
to support matching multiple cache keys.RoundedCornersTransformation
now crops to the size of the target then rounds the corners.CircleCropTransformation
now crops from the center.Scale.FIT
.MovieDrawable
not scaling properly.androidx.exifinterface:exifinterface
-> 1.1.0SvgDrawable
has been removed. Instead, SVGs are now prerendered to BitmapDrawable
s by SvgDecoder
. This makes SVGs significantly less expensive to render on the main thread. Also SvgDecoder
now requires a Context
in its constructor.SparseIntArraySet
extension functions have moved to the coil.extension
package.Parameters
API to support passing custom data through the image pipeline.ImageView.clear()
to support proactively freeing resources.subtractPadding
attribute to ViewSizeResolver to enable/disable subtracting a view's padding when measuring.RequestBuilder<*>.repeatCount
to set the repeat count for a GIF.@MainThread
.appcompat-resources
from compileOnly
to implementation
for coil-base
.ImageLoaderBuilder.okHttpClient(OkHttpClient.Builder.() -> Unit)
is now ImageLoaderBuilder.okHttpClient(() -> OkHttpClient)
. The initializer is also now called lazily on a background thread. If you set a custom OkHttpClient
you must set OkHttpClient.cache
to enable disk caching. If you don't set a custom OkHttpClient
, Coil will create the default OkHttpClient
which has disk caching enabled. The default Coil cache can be created using CoilUtils.createDefaultCache(context)
. e.g.:val imageLoader = ImageLoader(context) {
+ okHttpClient {
+ OkHttpClient.Builder()
+ .cache(CoilUtils.createDefaultCache(context))
+ .build()
+ }
+}
+
Fetcher.key
no longer has a default implementation.Mapper
would be called. Now, all applicable Mapper
s will be called. No API changes.url
-> uri
, factory
-> initializer
.coil-svg
artifact, which has an SvgDecoder
that supports automatically decoding SVGs. Powered by AndroidSVG. Thanks @rharter.load(String)
and get(String)
now accept any of the supported Uri schemes. e.g. You can now do imageView.load("file:///path/to/file.jpg")
.Call.Factory
instead of OkHttpClient
. This allows lazy initialization of the networking resources using ImageLoaderBuilder.okHttpClient { OkHttpClient() }
. Thanks @ZacSweers.RequestBuilder.decoder
to explicitly set the decoder for a request.ImageLoaderBuilder.allowHardware
to enable/disable hardware bitmaps by default for an ImageLoader.androidx.appcompat:appcompat
-> 1.1.0androidx.core:core-ktx
-> 1.1.0androidx.lifecycle:lifecycle-common-java8
-> 2.1.0appcompat
with appcompat-resources
as an optional compileOnly
dependency. appcompat-resources
is a much smaller artifact.transformations(List<Transformation>)
to RequestBuilder.