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

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

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

# encodeImage

[common]\
fun [encodeImage](encodeImage.md)(image: [Tensor](../Tensor/index.md)): [ByteArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html)

Encode a host image tensor as a PNG payload: `[H, W]` or `[H, W, C]` channels-last, UInt8 with 1, 3 or 4 channels, or a UInt16 single channel (16-bit gray). The PNG carries no color profile, so a decoder never changes the pixel values; a class-index mask or a depth map round-trips exactly.