# Bitmap.CompressFormat

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# CompressFormat

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat "View this page in Java")  

```
class CompressFormat
```

|---|---|----------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                      |||
| ↳ | [kotlin.Enum](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-enum/index.html)\<[android.graphics.Bitmap.CompressFormat](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#)\> ||
|   | ↳ | [android.graphics.Bitmap.CompressFormat](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#) |

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [Bitmap.CompressFormat.JPEG](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:JPEG),[Bitmap.CompressFormat.PNG](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:PNG),[Bitmap.CompressFormat.WEBP](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:WEBP),[Bitmap.CompressFormat.WEBP_LOSSLESS](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:WEBP_LOSSLESS),[Bitmap.CompressFormat.WEBP_LOSSY](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:WEBP_LOSSY) |-------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------| | [Bitmap.CompressFormat.JPEG](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:JPEG)                   | Compress to the JPEG format.          | | [Bitmap.CompressFormat.PNG](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:PNG)                     | Compress to the PNG format.           | | [Bitmap.CompressFormat.WEBP](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:WEBP)                   | Compress to the WEBP format.          | | [Bitmap.CompressFormat.WEBP_LOSSLESS](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:WEBP_LOSSLESS) | Compress to the WEBP lossless format. | | [Bitmap.CompressFormat.WEBP_LOSSY](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:WEBP_LOSSY)       | Compress to the WEBP lossy format.    | |

Specifies the known formats a bitmap can be compressed into

## Summary

|                                                                               Enum values                                                                                ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [JPEG](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:JPEG) Compress to the JPEG format.                            |
| [PNG](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:PNG) Compress to the PNG format.                               |
| [WEBP](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:WEBP) Compress to the WEBP format.                            |
| [WEBP_LOSSLESS](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:WEBP_LOSSLESS) Compress to the WEBP lossless format. |
| [WEBP_LOSSY](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#ENUM_VALUE:WEBP_LOSSY) Compress to the WEBP lossy format.          |

## Enum values

### JPEG

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
enum val JPEG : Bitmap.CompressFormat
```

Compress to the JPEG format.`quality`of`0`means compress for the smallest size.`100`means compress for max visual quality.  

### PNG

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
enum val PNG : Bitmap.CompressFormat
```

Compress to the PNG format. PNG is lossless, so`quality`is ignored.  

### WEBP

Added in[API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Deprecated in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
enum val WEBP : Bitmap.CompressFormat
```

**Deprecated:** *in favor of the more explicit[CompressFormat.WEBP_LOSSY](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#)and[CompressFormat.WEBP_LOSSLESS](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.CompressFormat#).*

Compress to the WEBP format.`quality`of`0`means compress for the smallest size.`100`means compress for max visual quality. As of[android.os.Build.VERSION_CODES#Q](https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#Q:kotlin.Int), a value of`100`results in a file in the lossless WEBP format. Otherwise the file will be in the lossy WEBP format.  

### WEBP_LOSSLESS

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
enum val WEBP_LOSSLESS : Bitmap.CompressFormat
```

Compress to the WEBP lossless format.`quality`refers to how much effort to put into compression. A value of`0`means to compress quickly, resulting in a relatively large file size.`100`means to spend more time compressing, resulting in a smaller file.  

### WEBP_LOSSY

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
enum val WEBP_LOSSY : Bitmap.CompressFormat
```

Compress to the WEBP lossy format.`quality`of`0`means compress for the smallest size.`100`means compress for max visual quality.