Buckets:

download
raw
53.6 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;utils/image&quot;,&quot;local&quot;:&quot;utilsimage&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;utils/image.RawImage&quot;,&quot;local&quot;:&quot;utilsimagerawimage&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;new RawImage(data, width, height, channels)&quot;,&quot;local&quot;:&quot;new-rawimagedata-width-height-channels&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.size ⇒ Array&quot;,&quot;local&quot;:&quot;rawimagesize--array&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.grayscale() ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimagegrayscale--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.rgb() ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimagergb--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.rgba() ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimagergba--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.putAlpha(mask) ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimageputalphamask--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.resize(width, height, options) ⇒ Promise. < RawImage >&quot;,&quot;local&quot;:&quot;rawimageresizewidth-height-options--promise--rawimage-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.split() ⇒ Array&quot;,&quot;local&quot;:&quot;rawimagesplit--array&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.clone() ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimageclone--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.convert(numChannels) ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimageconvertnumchannels--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.save(path) ⇒ Promise. < void >&quot;,&quot;local&quot;:&quot;rawimagesavepath--promise--void-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.toSharp() ⇒ Sharp&quot;,&quot;local&quot;:&quot;rawimagetosharp--sharp&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RawImage.read(input) ⇒ Promise. < RawImage >&quot;,&quot;local&quot;:&quot;rawimagereadinput--promise--rawimage-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RawImage.fromCanvas(canvas) ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimagefromcanvascanvas--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RawImage.fromURL(url) ⇒ Promise. < RawImage >&quot;,&quot;local&quot;:&quot;rawimagefromurlurl--promise--rawimage-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RawImage.fromBlob(blob) ⇒ Promise. < RawImage >&quot;,&quot;local&quot;:&quot;rawimagefromblobblob--promise--rawimage-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RawImage.fromTensor(tensor)&quot;,&quot;local&quot;:&quot;rawimagefromtensortensor&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/image.load_image&quot;,&quot;local&quot;:&quot;utilsimageloadimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/image~CONTENT_TYPE_MAP&quot;,&quot;local&quot;:&quot;utilsimagecontenttypemap&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}">
<link href="/docs/transformers.js/pr_1649/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/entry/start.5f753a22.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/scheduler.6efaaf90.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/singletons.c0807d75.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/paths.c5938264.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/entry/app.db3dfcb7.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/preload-helper.1d8e1e5d.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/index.eb3e1f0f.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/nodes/0.1b727385.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/each.e59479a4.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/nodes/19.a7817768.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.16f13047.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/CodeBlock.72c8dd07.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;utils/image&quot;,&quot;local&quot;:&quot;utilsimage&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;utils/image.RawImage&quot;,&quot;local&quot;:&quot;utilsimagerawimage&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;new RawImage(data, width, height, channels)&quot;,&quot;local&quot;:&quot;new-rawimagedata-width-height-channels&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.size ⇒ Array&quot;,&quot;local&quot;:&quot;rawimagesize--array&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.grayscale() ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimagegrayscale--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.rgb() ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimagergb--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.rgba() ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimagergba--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.putAlpha(mask) ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimageputalphamask--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.resize(width, height, options) ⇒ Promise. < RawImage >&quot;,&quot;local&quot;:&quot;rawimageresizewidth-height-options--promise--rawimage-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.split() ⇒ Array&quot;,&quot;local&quot;:&quot;rawimagesplit--array&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.clone() ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimageclone--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.convert(numChannels) ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimageconvertnumchannels--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.save(path) ⇒ Promise. < void >&quot;,&quot;local&quot;:&quot;rawimagesavepath--promise--void-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rawImage.toSharp() ⇒ Sharp&quot;,&quot;local&quot;:&quot;rawimagetosharp--sharp&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RawImage.read(input) ⇒ Promise. < RawImage >&quot;,&quot;local&quot;:&quot;rawimagereadinput--promise--rawimage-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RawImage.fromCanvas(canvas) ⇒ RawImage&quot;,&quot;local&quot;:&quot;rawimagefromcanvascanvas--rawimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RawImage.fromURL(url) ⇒ Promise. < RawImage >&quot;,&quot;local&quot;:&quot;rawimagefromurlurl--promise--rawimage-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RawImage.fromBlob(blob) ⇒ Promise. < RawImage >&quot;,&quot;local&quot;:&quot;rawimagefromblobblob--promise--rawimage-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RawImage.fromTensor(tensor)&quot;,&quot;local&quot;:&quot;rawimagefromtensortensor&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/image.load_image&quot;,&quot;local&quot;:&quot;utilsimageloadimage&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/image~CONTENT_TYPE_MAP&quot;,&quot;local&quot;:&quot;utilsimagecontenttypemap&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <a id="module_utils/image" class="group"></a> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <h1 class="relative group"><a id="utilsimage" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#utilsimage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>utils/image</span></h1> <p data-svelte-h="svelte-1uts7np">Helper module for image processing.</p> <p data-svelte-h="svelte-il3kl8">These functions and classes are only used internally,
meaning an end-user shouldn’t need to access anything here.</p> <ul data-svelte-h="svelte-1oeesep"><li><a href="#module_utils/image">utils/image</a> <ul><li><em>static</em> <ul><li><a href="#module_utils/image.RawImage">.RawImage</a> <ul><li><a href="#new_module_utils/image.RawImage_new"><code>new RawImage(data, width, height, channels)</code></a></li> <li><em>instance</em> <ul><li><a href="#module_utils/image.RawImage+size"><code>.size</code></a><code>Array</code></li> <li><a href="#module_utils/image.RawImage+grayscale"><code>.grayscale()</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage+rgb"><code>.rgb()</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage+rgba"><code>.rgba()</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage+putAlpha"><code>.putAlpha(mask)</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage+resize"><code>.resize(width, height, options)</code></a><a href="#RawImage"><code>Promise.&lt;RawImage&gt;</code></a></li> <li><a href="#module_utils/image.RawImage+split"><code>.split()</code></a><code>Array</code></li> <li><a href="#module_utils/image.RawImage+clone"><code>.clone()</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage+convert"><code>.convert(numChannels)</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage+save"><code>.save(path)</code></a><code>Promise.&lt;void&gt;</code></li> <li><a href="#module_utils/image.RawImage+toSharp"><code>.toSharp()</code></a><code>Sharp</code></li></ul></li> <li><em>static</em> <ul><li><a href="#module_utils/image.RawImage.read"><code>.read(input)</code></a><a href="#RawImage"><code>Promise.&lt;RawImage&gt;</code></a></li> <li><a href="#module_utils/image.RawImage.fromCanvas"><code>.fromCanvas(canvas)</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage.fromURL"><code>.fromURL(url)</code></a><a href="#RawImage"><code>Promise.&lt;RawImage&gt;</code></a></li> <li><a href="#module_utils/image.RawImage.fromBlob"><code>.fromBlob(blob)</code></a><a href="#RawImage"><code>Promise.&lt;RawImage&gt;</code></a></li> <li><a href="#module_utils/image.RawImage.fromTensor"><code>.fromTensor(tensor)</code></a></li></ul></li></ul></li> <li><a href="#module_utils/image.load_image"><code>.load_image</code></a></li></ul></li> <li><em>inner</em> <ul><li><a href="#module_utils/image..CONTENT_TYPE_MAP"><code>~CONTENT_TYPE_MAP</code></a></li></ul></li></ul></li></ul> <hr> <a id="module_utils/image.RawImage" class="group"></a> <h2 class="relative group"><a id="utilsimagerawimage" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#utilsimagerawimage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>utils/image.RawImage</span></h2> <p data-svelte-h="svelte-f7iksk"><strong>Kind</strong>: static class of <a href="#module_utils/image"><code>utils/image</code></a></p> <ul data-svelte-h="svelte-hnljmk"><li><a href="#module_utils/image.RawImage">.RawImage</a> <ul><li><a href="#new_module_utils/image.RawImage_new"><code>new RawImage(data, width, height, channels)</code></a></li> <li><em>instance</em> <ul><li><a href="#module_utils/image.RawImage+size"><code>.size</code></a><code>Array</code></li> <li><a href="#module_utils/image.RawImage+grayscale"><code>.grayscale()</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage+rgb"><code>.rgb()</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage+rgba"><code>.rgba()</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage+putAlpha"><code>.putAlpha(mask)</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage+resize"><code>.resize(width, height, options)</code></a><a href="#RawImage"><code>Promise.&lt;RawImage&gt;</code></a></li> <li><a href="#module_utils/image.RawImage+split"><code>.split()</code></a><code>Array</code></li> <li><a href="#module_utils/image.RawImage+clone"><code>.clone()</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage+convert"><code>.convert(numChannels)</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage+save"><code>.save(path)</code></a><code>Promise.&lt;void&gt;</code></li> <li><a href="#module_utils/image.RawImage+toSharp"><code>.toSharp()</code></a><code>Sharp</code></li></ul></li> <li><em>static</em> <ul><li><a href="#module_utils/image.RawImage.read"><code>.read(input)</code></a><a href="#RawImage"><code>Promise.&lt;RawImage&gt;</code></a></li> <li><a href="#module_utils/image.RawImage.fromCanvas"><code>.fromCanvas(canvas)</code></a><a href="#RawImage"><code>RawImage</code></a></li> <li><a href="#module_utils/image.RawImage.fromURL"><code>.fromURL(url)</code></a><a href="#RawImage"><code>Promise.&lt;RawImage&gt;</code></a></li> <li><a href="#module_utils/image.RawImage.fromBlob"><code>.fromBlob(blob)</code></a><a href="#RawImage"><code>Promise.&lt;RawImage&gt;</code></a></li> <li><a href="#module_utils/image.RawImage.fromTensor"><code>.fromTensor(tensor)</code></a></li></ul></li></ul></li></ul> <hr> <a id="new_module_utils/image.RawImage_new" class="group"></a> <h3 class="relative group"><a id="new-rawimagedata-width-height-channels" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#new-rawimagedata-width-height-channels"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>new RawImage(data, width, height, channels)</span></h3> <p data-svelte-h="svelte-36fe9a">Create a new <code>RawImage</code> object.</p> <table data-svelte-h="svelte-vkeoul"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>data</td><td><code>Uint8ClampedArray</code> | <code>Uint8Array</code></td><td><p>The pixel data.</p></td> </tr><tr><td>width</td><td><code>number</code></td><td><p>The width of the image.</p></td> </tr><tr><td>height</td><td><code>number</code></td><td><p>The height of the image.</p></td> </tr><tr><td>channels</td><td><code>1</code> | <code>2</code> | <code>3</code> | <code>4</code></td><td><p>The number of channels.</p></td></tr></tbody></table> <hr> <a id="module_utils/image.RawImage+size" class="group"></a> <h3 class="relative group"><a id="rawimagesize--array" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimagesize--array"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>rawImage.size ⇒ Array</span></h3> <p data-svelte-h="svelte-2j0n9s">Returns the size of the image (width, height).</p> <p data-svelte-h="svelte-dttlz"><strong>Kind</strong>: instance property of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <code>Array</code> - The size of the image (width, height).</p> <hr> <a id="module_utils/image.RawImage+grayscale" class="group"></a> <h3 class="relative group"><a id="rawimagegrayscale--rawimage" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimagegrayscale--rawimage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>rawImage.grayscale() ⇒ RawImage</span></h3> <p data-svelte-h="svelte-1owjjfe">Convert the image to grayscale format.</p> <p data-svelte-h="svelte-wnhar1"><strong>Kind</strong>: instance method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <a href="#RawImage"><code>RawImage</code></a> - <code>this</code> to support chaining.</p> <hr> <a id="module_utils/image.RawImage+rgb" class="group"></a> <h3 class="relative group"><a id="rawimagergb--rawimage" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimagergb--rawimage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>rawImage.rgb() ⇒ RawImage</span></h3> <p data-svelte-h="svelte-qyo04e">Convert the image to RGB format.</p> <p data-svelte-h="svelte-wnhar1"><strong>Kind</strong>: instance method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <a href="#RawImage"><code>RawImage</code></a> - <code>this</code> to support chaining.</p> <hr> <a id="module_utils/image.RawImage+rgba" class="group"></a> <h3 class="relative group"><a id="rawimagergba--rawimage" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimagergba--rawimage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>rawImage.rgba() ⇒ RawImage</span></h3> <p data-svelte-h="svelte-19kp14j">Convert the image to RGBA format.</p> <p data-svelte-h="svelte-wnhar1"><strong>Kind</strong>: instance method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <a href="#RawImage"><code>RawImage</code></a> - <code>this</code> to support chaining.</p> <hr> <a id="module_utils/image.RawImage+putAlpha" class="group"></a> <h3 class="relative group"><a id="rawimageputalphamask--rawimage" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimageputalphamask--rawimage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>rawImage.putAlpha(mask) ⇒ RawImage</span></h3> <p data-svelte-h="svelte-1r4j26z">Apply an alpha mask to the image. Operates in place.</p> <p data-svelte-h="svelte-1uu1yss"><strong>Kind</strong>: instance method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <a href="#RawImage"><code>RawImage</code></a> - The masked image.<br> <strong>Throws</strong>:</p> <ul data-svelte-h="svelte-17ls8t9"><li><code>Error</code> If the mask is not the same size as the image.</li> <li><code>Error</code> If the image does not have 4 channels.</li> <li><code>Error</code> If the mask is not a single channel.</li></ul> <table data-svelte-h="svelte-1bvqhoj"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>mask</td><td><code><a href="#RawImage">RawImage</a></code></td><td><p>The mask to apply. It should have a single channel.</p></td></tr></tbody></table> <hr> <a id="module_utils/image.RawImage+resize" class="group"></a> <h3 class="relative group"><a id="rawimageresizewidth-height-options--promise--rawimage-" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimageresizewidth-height-options--promise--rawimage-"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>rawImage.resize(width, height, options) ⇒ Promise. &lt; RawImage ></span></h3> <p data-svelte-h="svelte-s4dm9o">Resize the image to the given dimensions. This method uses the canvas API to perform the resizing.</p> <p data-svelte-h="svelte-1eyxxva"><strong>Kind</strong>: instance method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <a href="#RawImage"><code>Promise.&lt;RawImage&gt;</code></a> - <code>this</code> to support chaining.</p> <table data-svelte-h="svelte-h7uulu"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>width</td><td><code>number</code></td><td><p>The width of the new image. <code>null</code> or <code>-1</code> will preserve the aspect ratio.</p></td> </tr><tr><td>height</td><td><code>number</code></td><td><p>The height of the new image. <code>null</code> or <code>-1</code> will preserve the aspect ratio.</p></td> </tr><tr><td>options</td><td><code>Object</code></td><td><p>Additional options for resizing.</p></td> </tr><tr><td>[options.resample]</td><td><code>0</code> | <code>1</code> | <code>2</code> | <code>3</code> | <code>4</code> | <code>5</code> | <code>string</code></td><td><p>The resampling method to use.</p></td></tr></tbody></table> <hr> <a id="module_utils/image.RawImage+split" class="group"></a> <h3 class="relative group"><a id="rawimagesplit--array" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimagesplit--array"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>rawImage.split() ⇒ Array</span></h3> <p data-svelte-h="svelte-2m63ix">Split this image into individual bands. This method returns an array of individual image bands from an image.
For example, splitting an “RGB” image creates three new images each containing a copy of one of the original bands (red, green, blue).</p> <p data-svelte-h="svelte-k44jcf">Inspired by PIL’s <code>Image.split()</code> <a href="https://pillow.readthedocs.io/en/latest/reference/Image.html#PIL.Image.Image.split" rel="nofollow">function</a>.</p> <p data-svelte-h="svelte-vs2800"><strong>Kind</strong>: instance method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <code>Array</code> - An array containing bands.</p> <hr> <a id="module_utils/image.RawImage+clone" class="group"></a> <h3 class="relative group"><a id="rawimageclone--rawimage" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimageclone--rawimage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>rawImage.clone() ⇒ RawImage</span></h3> <p data-svelte-h="svelte-1eu6jk3">Clone the image</p> <p data-svelte-h="svelte-14yxs34"><strong>Kind</strong>: instance method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <a href="#RawImage"><code>RawImage</code></a> - The cloned image</p> <hr> <a id="module_utils/image.RawImage+convert" class="group"></a> <h3 class="relative group"><a id="rawimageconvertnumchannels--rawimage" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimageconvertnumchannels--rawimage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>rawImage.convert(numChannels) ⇒ RawImage</span></h3> <p data-svelte-h="svelte-5ze294">Helper method for converting image to have a certain number of channels</p> <p data-svelte-h="svelte-wnhar1"><strong>Kind</strong>: instance method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <a href="#RawImage"><code>RawImage</code></a> - <code>this</code> to support chaining.</p> <table data-svelte-h="svelte-1hxqxaq"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>numChannels</td><td><code>number</code></td><td><p>The number of channels. Must be 1, 3, or 4.</p></td></tr></tbody></table> <hr> <a id="module_utils/image.RawImage+save" class="group"></a> <h3 class="relative group"><a id="rawimagesavepath--promise--void-" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimagesavepath--promise--void-"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>rawImage.save(path) ⇒ Promise. &lt; void ></span></h3> <p data-svelte-h="svelte-119su55">Save the image to the given path.</p> <p data-svelte-h="svelte-1epyezb"><strong>Kind</strong>: instance method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a></p> <table data-svelte-h="svelte-1h4z9xq"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>path</td><td><code>string</code></td><td><p>The path to save the image to.</p></td></tr></tbody></table> <hr> <a id="module_utils/image.RawImage+toSharp" class="group"></a> <h3 class="relative group"><a id="rawimagetosharp--sharp" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimagetosharp--sharp"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>rawImage.toSharp() ⇒ Sharp</span></h3> <p data-svelte-h="svelte-76c9ym">Convert the image to a Sharp instance.</p> <p data-svelte-h="svelte-1i8zf3b"><strong>Kind</strong>: instance method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <code>Sharp</code> - The Sharp instance.</p> <hr> <a id="module_utils/image.RawImage.read" class="group"></a> <h3 class="relative group"><a id="rawimagereadinput--promise--rawimage-" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimagereadinput--promise--rawimage-"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>RawImage.read(input) ⇒ Promise. &lt; RawImage ></span></h3> <p data-svelte-h="svelte-5659h9">Helper method for reading an image from a variety of input types.</p> <p data-svelte-h="svelte-1hg19xa"><strong>Kind</strong>: static method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <a href="#RawImage"><code>Promise.&lt;RawImage&gt;</code></a> - The image object.</p> <p data-svelte-h="svelte-14z54gq"><strong>Example:</strong> Read image from a URL.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">let</span> image = <span class="hljs-keyword">await</span> <span class="hljs-title class_">RawImage</span>.<span class="hljs-title function_">read</span>(<span class="hljs-string">&#x27;https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/football-match.jpg&#x27;</span>);
<span class="hljs-comment">// RawImage {</span>
<span class="hljs-comment">// &quot;data&quot;: Uint8ClampedArray [ 25, 25, 25, 19, 19, 19, ... ],</span>
<span class="hljs-comment">// &quot;width&quot;: 800,</span>
<span class="hljs-comment">// &quot;height&quot;: 533,</span>
<span class="hljs-comment">// &quot;channels&quot;: 3</span>
<span class="hljs-comment">// }</span><!-- HTML_TAG_END --></pre></div> <table data-svelte-h="svelte-6lf1w0"><thead><tr><th>Param</th><th>Type</th></tr></thead> <tbody><tr><td>input</td><td><code><a href="#RawImage">RawImage</a></code> | <code>string</code> | <code>URL</code> | <code>Blob</code> | <code>HTMLCanvasElement</code> | <code>OffscreenCanvas</code></td></tr></tbody></table> <hr> <a id="module_utils/image.RawImage.fromCanvas" class="group"></a> <h3 class="relative group"><a id="rawimagefromcanvascanvas--rawimage" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimagefromcanvascanvas--rawimage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>RawImage.fromCanvas(canvas) ⇒ RawImage</span></h3> <p data-svelte-h="svelte-mjjjch">Read an image from a canvas.</p> <p data-svelte-h="svelte-uuk5nt"><strong>Kind</strong>: static method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <a href="#RawImage"><code>RawImage</code></a> - The image object.</p> <table data-svelte-h="svelte-hzvu44"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>canvas</td><td><code>HTMLCanvasElement</code> | <code>OffscreenCanvas</code></td><td><p>The canvas to read the image from.</p></td></tr></tbody></table> <hr> <a id="module_utils/image.RawImage.fromURL" class="group"></a> <h3 class="relative group"><a id="rawimagefromurlurl--promise--rawimage-" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimagefromurlurl--promise--rawimage-"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>RawImage.fromURL(url) ⇒ Promise. &lt; RawImage ></span></h3> <p data-svelte-h="svelte-1355z3u">Read an image from a URL or file path.</p> <p data-svelte-h="svelte-1vm5ou6"><strong>Kind</strong>: static method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <a href="#RawImage"><code>Promise.&lt;RawImage&gt;</code></a> - The image object.</p> <table data-svelte-h="svelte-ncveta"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>url</td><td><code>string</code> | <code>URL</code></td><td><p>The URL or file path to read the image from.</p></td></tr></tbody></table> <hr> <a id="module_utils/image.RawImage.fromBlob" class="group"></a> <h3 class="relative group"><a id="rawimagefromblobblob--promise--rawimage-" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimagefromblobblob--promise--rawimage-"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>RawImage.fromBlob(blob) ⇒ Promise. &lt; RawImage ></span></h3> <p data-svelte-h="svelte-1s704mu">Helper method to create a new Image from a blob.</p> <p data-svelte-h="svelte-1vm5ou6"><strong>Kind</strong>: static method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a><br> <strong>Returns</strong>: <a href="#RawImage"><code>Promise.&lt;RawImage&gt;</code></a> - The image object.</p> <table data-svelte-h="svelte-34rbhe"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>blob</td><td><code>Blob</code></td><td><p>The blob to read the image from.</p></td></tr></tbody></table> <hr> <a id="module_utils/image.RawImage.fromTensor" class="group"></a> <h3 class="relative group"><a id="rawimagefromtensortensor" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rawimagefromtensortensor"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>RawImage.fromTensor(tensor)</span></h3> <p data-svelte-h="svelte-nwy2y">Helper method to create a new Image from a tensor</p> <p data-svelte-h="svelte-sl3vqa"><strong>Kind</strong>: static method of <a href="#module_utils/image.RawImage"><code>RawImage</code></a></p> <table data-svelte-h="svelte-16eqzfb"><thead><tr><th>Param</th><th>Type</th></tr></thead> <tbody><tr><td>tensor</td><td><code><a href="#Tensor">Tensor</a></code></td></tr></tbody></table> <hr> <a id="module_utils/image.load_image" class="group"></a> <h2 class="relative group"><a id="utilsimageloadimage" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#utilsimageloadimage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>utils/image.load_image</span></h2> <p data-svelte-h="svelte-eu8o7o">Helper function to load an image from a URL, path, etc.</p> <p data-svelte-h="svelte-1ricti2"><strong>Kind</strong>: static constant of <a href="#module_utils/image"><code>utils/image</code></a></p> <hr> <a id="module_utils/image..CONTENT_TYPE_MAP" class="group"></a> <h2 class="relative group"><a id="utilsimagecontenttypemap" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#utilsimagecontenttypemap"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>utils/image~CONTENT_TYPE_MAP</span></h2> <p data-svelte-h="svelte-15u13r6">Mapping from file extensions to MIME types.</p> <p data-svelte-h="svelte-1cwm6ga"><strong>Kind</strong>: inner constant of <a href="#module_utils/image"><code>utils/image</code></a></p> <hr> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/transformers.js/blob/main/packages/transformers/docs/source/api/utils/image.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg> <span data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p>
<script>
{
__sveltekit_rvrl7f = {
assets: "/docs/transformers.js/pr_1649/en",
base: "/docs/transformers.js/pr_1649/en",
env: {}
};
const element = document.currentScript.parentElement;
const data = [null,null];
Promise.all([
import("/docs/transformers.js/pr_1649/en/_app/immutable/entry/start.5f753a22.js"),
import("/docs/transformers.js/pr_1649/en/_app/immutable/entry/app.db3dfcb7.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 19],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
53.6 kB
·
Xet hash:
0f6cd870da08f48b20753d4b965c9d02de7d99a53a28cf2245ea716f7a9a1950

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.