<!DOCTYPE html><htmlclass="default"lang="en"><head><metacharSet="utf-8"/><metahttp-equiv="x-ua-compatible"content="IE=edge"/><title>toPixels | @vladmandic/face-api - v1.7.13</title><metaname="description"content="Documentation for @vladmandic/face-api"/><metaname="viewport"content="width=device-width, initial-scale=1"/><linkrel="stylesheet"href="../assets/style.css"/><linkrel="stylesheet"href="../assets/highlight.css"/><scriptdefersrc="../assets/main.js"></script><scriptasyncsrc="../assets/search.js"id="tsd-search-script"></script><scriptasyncsrc="../assets/navigation.js"id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme=localStorage.getItem("tsd-theme")||"os"</script><headerclass="tsd-page-toolbar"><divclass="tsd-toolbar-contents container"><divclass="table-cell"id="tsd-search"data-base=".."><divclass="field"><labelfor="tsd-search-field"class="tsd-widget tsd-toolbar-icon search no-caption"><svgwidth="16"height="16"viewBox="0 0 16 16"fill="none"><usehref="#icon-search"></use></svg></label><inputtype="text"id="tsd-search-field"aria-label="Search"/></div><divclass="field"><divid="tsd-toolbar-links"></div></div><ulclass="results"><liclass="state loading">Preparing search index...</li><liclass="state failure">The search index is not available</li></ul><ahref="../index.html"class="title">@vladmandic/face-api - v1.7.13</a></div><divclass="table-cell"id="tsd-widgets"><ahref="#"class="tsd-widget tsd-toolbar-icon menu no-caption"data-toggle="menu"aria-label="Menu"><svgwidth="16"height="16"viewBox="0 0 16 16"fill="none"><usehref="#icon-menu"></use></svg></a></div></div></header><divclass="container container-main"><divclass="col-content"><divclass="tsd-page-title"><ulclass="tsd-breadcrumb"><li><ahref="../index.html">@vladmandic/face-api</a></li><li><ahref="../modules/tf.html">tf</a></li><li><ahref="../modules/tf.browser.html">browser</a></li><li><ahref="tf.browser.toPixels.html">toPixels</a></li></ul><h1>Function toPixels</h1></div><sectionclass="tsd-panel"><ulclass="tsd-signatures"><liclass="tsd-signature tsd-anchor-link"><aid="toPixels"class="tsd-anchor"></a><spanclass="tsd-kind-call-signature">to<wbr/>Pixels</span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">img</span>, <spanclass="tsd-kind-parameter">canvas</span><spanclass="tsd-signature-symbol">?</span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">: </span><spanclass="tsd-signature-type">Promise</span><spanclass="tsd-signature-symbol"><</span><spanclass="tsd-signature-type">Uint8ClampedArray</span><spanclass="tsd-signature-symbol">></span><ahref="#toPixels"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"><usehref="#icon-anchor"></use></svg></a></li><liclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Draws a <code>tf.Tensor</code> of pixel values to a byte array or optionally a
canvas.</p>
<p>When the dtype of the input is 'float32', we assume values in the range
[0-1]. Otherwise, when input is 'int32', we assume values in the range
[0-255].</p>
<p>Returns a promise that resolves when the canvas has been drawn to.</p>
</div><divclass="tsd-parameters"><h4class="tsd-parameters-title">Parameters</h4><ulclass="tsd-parameter-list"><li><h5><spanclass="tsd-kind-parameter">img</span>: <ahref="../types/tf.Tensor2D.html"class="tsd-signature-type tsd-kind-type-alias">Tensor2D</a><spanclass="tsd-signature-symbol"> | </span><ahref="../types/tf.TensorLike.html"class="tsd-signature-type tsd-kind-type-alias">TensorLike</a><spanclass="tsd-signature-symbol"> | </span><ahref="../types/tf.Tensor3D.html"class="tsd-signature-type tsd-kind-type-alias">Tensor3D</a></h5><divclass="tsd-comment tsd-typography"><p>A rank-2 tensor with shape <code>[height, width]</code>, or a rank-3 tensor
of shape <code>[height, width, numChannels]</code>. If rank-2, draws grayscale. If
rank-3, must have depth of 1, 3 or 4. When depth of 1, draws
grayscale. When depth of 3, we draw with the first three components of
the depth dimension corresponding to r, g, b and alpha = 1. When depth of
4, all four components of the depth dimension correspond to r, g, b, a.</p>
</div><divclass="tsd-comment tsd-typography"></div></li><li><h5><codeclass="tsd-tag ts-flagOptional">Optional</code><spanclass="tsd-kind-parameter">canvas</span>: <spanclass="tsd-signature-type">HTMLCanvasElement</span></h5><divclass="tsd-comment tsd-typography"><p>The canvas to draw to.</p>