Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/media/ThumbnailUtils#constants) \| [Ctors](https://developer.android.com/reference/android/media/ThumbnailUtils#pubctors) \| [Methods](https://developer.android.com/reference/android/media/ThumbnailUtils#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/media/ThumbnailUtils#inhmethods)

# ThumbnailUtils

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/media/ThumbnailUtils "View this page in Kotlin") \|Java


`
public


class
ThumbnailUtils
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.media.ThumbnailUtils |

<br />

*** ** * ** ***

Utilities for generating visual thumbnails from files.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/media/ThumbnailUtils#OPTIONS_RECYCLE_INPUT` Constant used to indicate we should recycle the input in `https://developer.android.com/reference/android/media/ThumbnailUtils#extractThumbnail(android.graphics.Bitmap,%20int,%20int,%20int)` unless the output is the input. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/media/ThumbnailUtils#ThumbnailUtils()() ` |

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/media/ThumbnailUtils#createAudioThumbnail(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String filePath, int kind) ` *This method was deprecated in API level 29. Callers should migrate to using `https://developer.android.com/reference/android/media/ThumbnailUtils#createAudioThumbnail(java.io.File,%20android.util.Size,%20android.os.CancellationSignal)`, as it offers more control over resizing and cancellation.* |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/media/ThumbnailUtils#createAudioThumbnail(java.io.File,%20android.util.Size,%20android.os.CancellationSignal)(https://developer.android.com/reference/java/io/File file, https://developer.android.com/reference/android/util/Size size, https://developer.android.com/reference/android/os/CancellationSignal signal) ` Create a thumbnail for given audio file. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/media/ThumbnailUtils#createImageThumbnail(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String filePath, int kind) ` *This method was deprecated in API level 29. Callers should migrate to using `https://developer.android.com/reference/android/media/ThumbnailUtils#createImageThumbnail(java.io.File,%20android.util.Size,%20android.os.CancellationSignal)`, as it offers more control over resizing and cancellation.* |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/media/ThumbnailUtils#createImageThumbnail(java.io.File,%20android.util.Size,%20android.os.CancellationSignal)(https://developer.android.com/reference/java/io/File file, https://developer.android.com/reference/android/util/Size size, https://developer.android.com/reference/android/os/CancellationSignal signal) ` Create a thumbnail for given image file. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/media/ThumbnailUtils#createVideoThumbnail(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String filePath, int kind) ` *This method was deprecated in API level 29. Callers should migrate to using `https://developer.android.com/reference/android/media/ThumbnailUtils#createVideoThumbnail(java.io.File,%20android.util.Size,%20android.os.CancellationSignal)`, as it offers more control over resizing and cancellation.* |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/media/ThumbnailUtils#createVideoThumbnail(java.io.File,%20android.util.Size,%20android.os.CancellationSignal)(https://developer.android.com/reference/java/io/File file, https://developer.android.com/reference/android/util/Size size, https://developer.android.com/reference/android/os/CancellationSignal signal) ` Create a thumbnail for given video file. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/media/ThumbnailUtils#extractThumbnail(android.graphics.Bitmap,%20int,%20int,%20int)(https://developer.android.com/reference/android/graphics/Bitmap source, int width, int height, int options) ` Creates a centered bitmap of the desired size. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/media/ThumbnailUtils#extractThumbnail(android.graphics.Bitmap,%20int,%20int)(https://developer.android.com/reference/android/graphics/Bitmap source, int width, int height) ` Creates a centered bitmap of the desired size. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Constants

### OPTIONS_RECYCLE_INPUT

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

```
public static final int OPTIONS_RECYCLE_INPUT
```

Constant used to indicate we should recycle the input in
`https://developer.android.com/reference/android/media/ThumbnailUtils#extractThumbnail(android.graphics.Bitmap,%20int,%20int,%20int)` unless the output is the input.

<br />

Constant Value:

2
(0x00000002)


## Public constructors

### ThumbnailUtils

```
public ThumbnailUtils ()
```

<br />

<br />

## Public methods

### createAudioThumbnail

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

```
public static Bitmap createAudioThumbnail (String filePath, 
                int kind)
```


**This method was deprecated
in API level 29.**   

Callers should migrate to using
`https://developer.android.com/reference/android/media/ThumbnailUtils#createAudioThumbnail(java.io.File,%20android.util.Size,%20android.os.CancellationSignal)`,
as it offers more control over resizing and cancellation.

Create a thumbnail for given audio file.

<br />

| Parameters ||
|---|---|
| `filePath` | `String`: The audio file. This value cannot be `null`. <br /> |
| `kind` | `int`: The desired thumbnail kind, such as `https://developer.android.com/reference/android/provider/MediaStore.Images.Thumbnails#MINI_KIND`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value may be `null`. <br /> |

### createAudioThumbnail

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

```
public static Bitmap createAudioThumbnail (File file, 
                Size size, 
                CancellationSignal signal)
```

Create a thumbnail for given audio file.


This method should only be used for files that you have direct access to;
if you'd like to work with media hosted outside your app, consider using
`https://developer.android.com/reference/android/content/ContentResolver#loadThumbnail(android.net.Uri,%20android.util.Size,%20android.os.CancellationSignal)`
which enables remote providers to efficiently cache and invalidate
thumbnails.

<br />

| Parameters ||
|---|---|
| `file` | `File`: The audio file. This value cannot be `null`. <br /> |
| `size` | `Size`: The desired thumbnail size. This value cannot be `null`. <br /> |
| `signal` | `CancellationSignal`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | If any trouble was encountered while generating or loading the thumbnail, or if `https://developer.android.com/reference/android/os/CancellationSignal#cancel()` was invoked. |

### createImageThumbnail

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

```
public static Bitmap createImageThumbnail (String filePath, 
                int kind)
```


**This method was deprecated
in API level 29.**   

Callers should migrate to using
`https://developer.android.com/reference/android/media/ThumbnailUtils#createImageThumbnail(java.io.File,%20android.util.Size,%20android.os.CancellationSignal)`,
as it offers more control over resizing and cancellation.

Create a thumbnail for given image file.

<br />

| Parameters ||
|---|---|
| `filePath` | `String`: The image file. This value cannot be `null`. <br /> |
| `kind` | `int`: The desired thumbnail kind, such as `https://developer.android.com/reference/android/provider/MediaStore.Images.Thumbnails#MINI_KIND`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value may be `null`. <br /> |

### createImageThumbnail

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

```
public static Bitmap createImageThumbnail (File file, 
                Size size, 
                CancellationSignal signal)
```

Create a thumbnail for given image file.


This method should only be used for files that you have direct access to;
if you'd like to work with media hosted outside your app, consider using
`https://developer.android.com/reference/android/content/ContentResolver#loadThumbnail(android.net.Uri,%20android.util.Size,%20android.os.CancellationSignal)`
which enables remote providers to efficiently cache and invalidate
thumbnails.

<br />

| Parameters ||
|---|---|
| `file` | `File`: The image file. This value cannot be `null`. <br /> |
| `size` | `Size`: The desired thumbnail size. This value cannot be `null`. <br /> |
| `signal` | `CancellationSignal`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | If any trouble was encountered while generating or loading the thumbnail, or if `https://developer.android.com/reference/android/os/CancellationSignal#cancel()` was invoked. |

### createVideoThumbnail

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

```
public static Bitmap createVideoThumbnail (String filePath, 
                int kind)
```


**This method was deprecated
in API level 29.**   

Callers should migrate to using
`https://developer.android.com/reference/android/media/ThumbnailUtils#createVideoThumbnail(java.io.File,%20android.util.Size,%20android.os.CancellationSignal)`,
as it offers more control over resizing and cancellation.

Create a thumbnail for given video file.

<br />

| Parameters ||
|---|---|
| `filePath` | `String`: The video file. This value cannot be `null`. <br /> |
| `kind` | `int`: The desired thumbnail kind, such as `https://developer.android.com/reference/android/provider/MediaStore.Images.Thumbnails#MINI_KIND`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value may be `null`. <br /> |

### createVideoThumbnail

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

```
public static Bitmap createVideoThumbnail (File file, 
                Size size, 
                CancellationSignal signal)
```

Create a thumbnail for given video file.


This method should only be used for files that you have direct access to;
if you'd like to work with media hosted outside your app, consider using
`https://developer.android.com/reference/android/content/ContentResolver#loadThumbnail(android.net.Uri,%20android.util.Size,%20android.os.CancellationSignal)`
which enables remote providers to efficiently cache and invalidate
thumbnails.

<br />

| Parameters ||
|---|---|
| `file` | `File`: The video file. This value cannot be `null`. <br /> |
| `size` | `Size`: The desired thumbnail size. This value cannot be `null`. <br /> |
| `signal` | `CancellationSignal`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | If any trouble was encountered while generating or loading the thumbnail, or if `https://developer.android.com/reference/android/os/CancellationSignal#cancel()` was invoked. |

### extractThumbnail

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

```
public static Bitmap extractThumbnail (Bitmap source, 
                int width, 
                int height, 
                int options)
```

Creates a centered bitmap of the desired size.

<br />

| Parameters ||
|---|---|
| `source` | `Bitmap`: original bitmap source <br /> |
| `width` | `int`: targeted width <br /> |
| `height` | `int`: targeted height <br /> |
| `options` | `int`: options used during thumbnail extraction <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | <br /> |

### extractThumbnail

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

```
public static Bitmap extractThumbnail (Bitmap source, 
                int width, 
                int height)
```

Creates a centered bitmap of the desired size.

<br />

| Parameters ||
|---|---|
| `source` | `Bitmap`: original bitmap source <br /> |
| `width` | `int`: targeted width <br /> |
| `height` | `int`: targeted height <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | <br /> |