---
title: "ImageProcessor"
sidebar_label: "ImageProcessor"
description: "Kotlin binding reference: ImageProcessor."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[ImageProcessor](index.md)

# ImageProcessor

[common]\
class [ImageProcessor](index.md)

A configuration-driven image preprocessor: convert to RGB, resize, center-crop, rescale, normalize and pad, as a model's `preprocessor_config.json` states them, to a `[H, W, C]` Float32 tensor (channels-last). Load one from a model directory, or build one from the common knobs with [fromArgs](Companion/fromArgs.md). `AutoCloseable`: [close](close.md) releases it.

```kotlin
ImageProcessor.fromHuggingface("/path/to/model").use { processor ->
    val pixels = processor.process("/path/photo.jpg")   // [H, W, 3] Float32
}
```

## Types

| Name | Summary |
|---|---|
| [Companion](Companion/index.md) | [common]<br>object [Companion](Companion/index.md) |

## Functions

| Name | Summary |
|---|---|
| [close](close.md) | [common]<br>open fun [close](close.md)() |
| [process](process.md) | [common]<br>fun [process](process.md)(image: [Tensor](../Tensor/index.md), options: [ImageProcessOptions](../ImageProcessOptions/index.md)? = null, where: [Placement](../Placement/index.md)? = null): [Tensor](../Tensor/index.md)<br>Preprocess decoded pixels: `[H, W, C]` (one image) or `[N, H, W, C]` (a batch) UInt8 channels-last.<br>[common]<br>fun [process](process.md)(bytes: [ByteArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html), options: [ImageProcessOptions](../ImageProcessOptions/index.md)? = null, where: [Placement](../Placement/index.md)? = null): [Tensor](../Tensor/index.md)<br>Preprocess an encoded image payload (PNG, JPEG, BMP, ...).<br>[common]<br>fun [process](process.md)(path: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), options: [ImageProcessOptions](../ImageProcessOptions/index.md)? = null, where: [Placement](../Placement/index.md)? = null): [Tensor](../Tensor/index.md)<br>Preprocess an image file; [options](process.md) override the configuration for this call, [where](process.md) the bound placement. |
| [processBatch](processBatch.md) | [common]<br>fun [processBatch](processBatch.md)(images: [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[ByteArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html)&gt;, options: [ImageProcessOptions](../ImageProcessOptions/index.md)? = null, where: [Placement](../Placement/index.md)? = null): [Tensor](../Tensor/index.md)<br>Preprocess a batch of encoded images to `[N, H, W, C]`; every image must come out at one size. |