UNPKG

node-libpng

Version:

Unofficial bindings for node to libpng.

965 lines (964 loc) 58.5 kB
<!doctype html> <html class="default no-js"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>PngImage | node-libpng</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="../assets/css/main.css"> </head> <body> <header> <div class="tsd-page-toolbar"> <div class="container"> <div class="table-wrap"> <div class="table-cell" id="tsd-search" data-index="../assets/js/search.js" data-base=".."> <div class="field"> <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label> <input id="tsd-search-field" type="text" /> </div> <ul class="results"> <li class="state loading">Preparing search index...</li> <li class="state failure">The search index is not available</li> </ul> <a href="../index.html" class="title">node-libpng</a> </div> <div class="table-cell" id="tsd-widgets"> <div id="tsd-filter"> <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a> <div class="tsd-filter-group"> <div class="tsd-select" id="tsd-filter-visibility"> <span class="tsd-select-label">All</span> <ul class="tsd-select-list"> <li data-value="public">Public</li> <li data-value="protected">Public/Protected</li> <li data-value="private" class="selected">All</li> </ul> </div> <input type="checkbox" id="tsd-filter-inherited" checked /> <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label> <input type="checkbox" id="tsd-filter-externals" checked /> <label class="tsd-widget" for="tsd-filter-externals">Externals</label> <input type="checkbox" id="tsd-filter-only-exported" /> <label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label> </div> </div> <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a> </div> </div> </div> </div> <div class="tsd-page-title"> <div class="container"> <ul class="tsd-breadcrumb"> <li> <a href="../globals.html">Globals</a> </li> <li> <a href="pngimage.html">PngImage</a> </li> </ul> <h1>Class PngImage</h1> </div> </div> </header> <div class="container container-main"> <div class="row"> <div class="col-8 col-content"> <section class="tsd-panel tsd-comment"> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Decodes and wraps a PNG image. Will call the native bindings under the hood and provides a high-level access to read- and write operations on the image.</p> </div> </div> </section> <section class="tsd-panel tsd-hierarchy"> <h3>Hierarchy</h3> <ul class="tsd-hierarchy"> <li> <span class="target">PngImage</span> </li> </ul> </section> <section class="tsd-panel-group tsd-index-group"> <h2>Index</h2> <section class="tsd-panel tsd-index-panel"> <div class="tsd-index-content"> <section class="tsd-index-section "> <h3>Constructors</h3> <ul class="tsd-index-list"> <li class="tsd-kind-constructor tsd-parent-kind-class"><a href="pngimage.html#constructor" class="tsd-kind-icon">constructor</a></li> </ul> </section> <section class="tsd-index-section "> <h3>Properties</h3> <ul class="tsd-index-list"> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#backgroundcolor" class="tsd-kind-icon">background<wbr>Color</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#bitdepth" class="tsd-kind-icon">bit<wbr>Depth</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#channels" class="tsd-kind-icon">channels</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#colortype" class="tsd-kind-icon">color<wbr>Type</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#data" class="tsd-kind-icon">data</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#gamma" class="tsd-kind-icon">gamma</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#height" class="tsd-kind-icon">height</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#interlacetype" class="tsd-kind-icon">interlace<wbr>Type</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#offsetx" class="tsd-kind-icon">offsetX</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#offsety" class="tsd-kind-icon">offsetY</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#palette" class="tsd-kind-icon">palette</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#pixelspermeterx" class="tsd-kind-icon">pixels<wbr>Per<wbr>MeterX</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#pixelspermetery" class="tsd-kind-icon">pixels<wbr>Per<wbr>MeterY</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#rowbytes" class="tsd-kind-icon">row<wbr>Bytes</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#time" class="tsd-kind-icon">time</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="pngimage.html#width" class="tsd-kind-icon">width</a></li> </ul> </section> <section class="tsd-index-section "> <h3>Accessors</h3> <ul class="tsd-index-list"> <li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="pngimage.html#alpha" class="tsd-kind-icon">alpha</a></li> <li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="pngimage.html#bytesperpixel" class="tsd-kind-icon">bytes<wbr>Per<wbr>Pixel</a></li> </ul> </section> <section class="tsd-index-section "> <h3>Methods</h3> <ul class="tsd-index-list"> <li class="tsd-kind-method tsd-parent-kind-class"><a href="pngimage.html#at" class="tsd-kind-icon">at</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="pngimage.html#copyfrom" class="tsd-kind-icon">copy<wbr>From</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="pngimage.html#crop" class="tsd-kind-icon">crop</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="pngimage.html#encode" class="tsd-kind-icon">encode</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="pngimage.html#fill" class="tsd-kind-icon">fill</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="pngimage.html#resizecanvas" class="tsd-kind-icon">resize<wbr>Canvas</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="pngimage.html#rgbaat" class="tsd-kind-icon">rgba<wbr>At</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="pngimage.html#set" class="tsd-kind-icon">set</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="pngimage.html#toindex" class="tsd-kind-icon">to<wbr>Index</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="pngimage.html#toxy" class="tsd-kind-icon">toXY</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="pngimage.html#write" class="tsd-kind-icon">write</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="pngimage.html#writesync" class="tsd-kind-icon">write<wbr>Sync</a></li> </ul> </section> </div> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Constructors</h2> <section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class"> <a name="constructor" class="tsd-anchor"></a> <h3>constructor</h3> <ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">new <wbr>Png<wbr>Image<span class="tsd-signature-symbol">(</span>buffer<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Buffer</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="pngimage.html" class="tsd-signature-type">PngImage</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L132">png-image.ts:132</a></li> </ul> </aside> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>buffer: <span class="tsd-signature-type">Buffer</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="pngimage.html" class="tsd-signature-type">PngImage</a></h4> </li> </ul> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Properties</h2> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="backgroundcolor" class="tsd-anchor"></a> <h3>background<wbr>Color</h3> <div class="tsd-signature tsd-kind-icon">background<wbr>Color<span class="tsd-signature-symbol">:</span> <a href="../globals.html#colorrgb" class="tsd-signature-type">ColorRGB</a><span class="tsd-signature-symbol"> | </span><a href="../globals.html#colorgrayscale" class="tsd-signature-type">ColorGrayScale</a><span class="tsd-signature-symbol"> | </span><a href="../globals.html#colorpalette" class="tsd-signature-type">ColorPalette</a></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L234">png-image.ts:234</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns the background color of the image if provided in the header.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="bitdepth" class="tsd-anchor"></a> <h3>bit<wbr>Depth</h3> <div class="tsd-signature tsd-kind-icon">bit<wbr>Depth<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L160">png-image.ts:160</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The bit depth of the image. Gathered from <code>png_get_bit_depth</code>.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="channels" class="tsd-anchor"></a> <h3>channels</h3> <div class="tsd-signature tsd-kind-icon">channels<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L166">png-image.ts:166</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The amount of channels of the image. Gathered from <code>png_get_channels</code>.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="colortype" class="tsd-anchor"></a> <h3>color<wbr>Type</h3> <div class="tsd-signature tsd-kind-icon">color<wbr>Type<span class="tsd-signature-symbol">:</span> <a href="../enums/colortype.html" class="tsd-signature-type">ColorType</a></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L172">png-image.ts:172</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The color type of the image as a string. Gathered from <code>png_get_color_type</code>.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="data" class="tsd-anchor"></a> <h3>data</h3> <div class="tsd-signature tsd-kind-icon">data<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Buffer</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L224">png-image.ts:224</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The buffer containing the data of the decoded image.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="gamma" class="tsd-anchor"></a> <h3>gamma</h3> <div class="tsd-signature tsd-kind-icon">gamma<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L247">png-image.ts:247</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The gamma value of the image. Gathered from <code>png_get_gAMA</code>.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="height" class="tsd-anchor"></a> <h3>height</h3> <div class="tsd-signature tsd-kind-icon">height<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L178">png-image.ts:178</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The width of the image. Gathered from <code>png_get_image_height</code>.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="interlacetype" class="tsd-anchor"></a> <h3>interlace<wbr>Type</h3> <div class="tsd-signature tsd-kind-icon">interlace<wbr>Type<span class="tsd-signature-symbol">:</span> <a href="../enums/interlacetype.html" class="tsd-signature-type">InterlaceType</a></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L189">png-image.ts:189</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The interlace type of the image as a string, gathered from <code>png_get_interlace_type</code>.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="offsetx" class="tsd-anchor"></a> <h3>offsetX</h3> <div class="tsd-signature tsd-kind-icon">offsetX<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L201">png-image.ts:201</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The horizontal offset of the image. Gathered from <code>png_get_x_offset_pixels</code>.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="offsety" class="tsd-anchor"></a> <h3>offsetY</h3> <div class="tsd-signature tsd-kind-icon">offsetY<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L207">png-image.ts:207</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The vertical offset of the image. Gathered from <code>png_get_y_offset_pixels</code>.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="palette" class="tsd-anchor"></a> <h3>palette</h3> <div class="tsd-signature tsd-kind-icon">palette<span class="tsd-signature-symbol">:</span> <a href="../globals.html#palette" class="tsd-signature-type">Palette</a></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L241">png-image.ts:241</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Retrieve the palette of this image if the color type is <code>ColorType.PALETTE</code>.</p> </div> <dl class="tsd-comment-tags"> <dt>see</dt> <dd><p>ColorType</p> </dd> </dl> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="pixelspermeterx" class="tsd-anchor"></a> <h3>pixels<wbr>Per<wbr>MeterX</h3> <div class="tsd-signature tsd-kind-icon">pixels<wbr>Per<wbr>MeterX<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L213">png-image.ts:213</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The horizontal amount of pixels per meter of the image. Gathered from <code>png_get_x_pixels_per_meter</code>.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="pixelspermetery" class="tsd-anchor"></a> <h3>pixels<wbr>Per<wbr>MeterY</h3> <div class="tsd-signature tsd-kind-icon">pixels<wbr>Per<wbr>MeterY<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L219">png-image.ts:219</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The vertical amount of pixels per meter of the image. Gathered from <code>png_get_y_pixels_per_meter</code>.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="rowbytes" class="tsd-anchor"></a> <h3>row<wbr>Bytes</h3> <div class="tsd-signature tsd-kind-icon">row<wbr>Bytes<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L195">png-image.ts:195</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The amount of bytes per row of the image. Gathered from <code>png_get_rowbytes</code>.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="time" class="tsd-anchor"></a> <h3>time</h3> <div class="tsd-signature tsd-kind-icon">time<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Date</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L229">png-image.ts:229</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns the last modification time as returned by <code>png_get_tIME</code>.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="width" class="tsd-anchor"></a> <h3>width</h3> <div class="tsd-signature tsd-kind-icon">width<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L184">png-image.ts:184</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The width of the image. Gathered from <code>png_get_image_width</code>.</p> </div> </div> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Accessors</h2> <section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class"> <a name="alpha" class="tsd-anchor"></a> <h3>alpha</h3> <ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> alpha<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L252">png-image.ts:252</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Will be <code>true</code> if the image&#39;s color type has an alpha channel and <code>false</code> otherwise.</p> </div> </div> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class"> <a name="bytesperpixel" class="tsd-anchor"></a> <h3>bytes<wbr>Per<wbr>Pixel</h3> <ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> bytesPerPixel<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L265">png-image.ts:265</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns the amount of bytes per pixel (depending on the color type) for the image.</p> </div> </div> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4> </li> </ul> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Methods</h2> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="at" class="tsd-anchor"></a> <h3>at</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">at<span class="tsd-signature-symbol">(</span>x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, y<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../globals.html#colorany" class="tsd-signature-type">ColorAny</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L307">png-image.ts:307</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Retrieves the color in the image&#39;s color format at the specified position.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>x: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>The x position of the pixel in the image of which to retrieve the color.</p> </div> </li> <li> <h5>y: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>The y position of the pixel in the image of which to retrieve the color.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="../globals.html#colorany" class="tsd-signature-type">ColorAny</a></h4> <p>The color at the given pixel in the image&#39;s color format.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="copyfrom" class="tsd-anchor"></a> <h3>copy<wbr>From</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">copy<wbr>From<span class="tsd-signature-symbol">(</span>other<span class="tsd-signature-symbol">: </span><a href="pngimage.html" class="tsd-signature-type">PngImage</a>, offset<span class="tsd-signature-symbol">?: </span><a href="../globals.html#xy" class="tsd-signature-type">XY</a>, source<span class="tsd-signature-symbol">?: </span><a href="../globals.html#rect" class="tsd-signature-type">Rect</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L412">png-image.ts:412</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Copies the specified rectangle from the other image (or the whole other image if rectangle is omitted) into this image at the current offset (or to the top left if the offset is omitted). Modifies this image and the underlying buffer.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>other: <a href="pngimage.html" class="tsd-signature-type">PngImage</a></h5> <div class="tsd-comment tsd-typography"> <p>The other image which should be copied into this image.</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> offset: <a href="../globals.html#xy" class="tsd-signature-type">XY</a></h5> <div class="tsd-comment tsd-typography"> <p>The target position in this image to which the other image should be copied.</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> source: <a href="../globals.html#rect" class="tsd-signature-type">Rect</a></h5> <div class="tsd-comment tsd-typography"> <p>The clipping rectangle of the other image which should be copied.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="crop" class="tsd-anchor"></a> <h3>crop</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">crop<span class="tsd-signature-symbol">(</span>clip<span class="tsd-signature-symbol">: </span><a href="../globals.html#rect" class="tsd-signature-type">Rect</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L352">png-image.ts:352</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>A convenience wrapper around <code>resizeCanvas</code>. Crops the image to a specified sub-rectangle. Modifies this image and the underlying buffer.</p> </div> <dl class="tsd-comment-tags"> <dt>see</dt> <dd><p>PngImage.resizeCanvas</p> </dd> <dt>see</dt> <dd><p>ResizeCanvasArguments</p> </dd> </dl> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>clip: <a href="../globals.html#rect" class="tsd-signature-type">Rect</a></h5> <div class="tsd-comment tsd-typography"> <p>A sub-rectangle which should be cropped out of the image.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="encode" class="tsd-anchor"></a> <h3>encode</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">encode<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Buffer</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L481">png-image.ts:481</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Will encode this image to a PNG buffer.</p> </div> </div> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Buffer</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="fill" class="tsd-anchor"></a> <h3>fill</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">fill<span class="tsd-signature-symbol">(</span>color<span class="tsd-signature-symbol">: </span><a href="../globals.html#colorany" class="tsd-signature-type">ColorAny</a>, area<span class="tsd-signature-symbol">?: </span><a href="../globals.html#rect" class="tsd-signature-type">Rect</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L449">png-image.ts:449</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Fill an area of the image with a specific color. This will change the underlying data of this image. The change is in-place.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>color: <a href="../globals.html#colorany" class="tsd-signature-type">ColorAny</a></h5> <div class="tsd-comment tsd-typography"> <p>The color with which the area should be filled.</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> area: <a href="../globals.html#rect" class="tsd-signature-type">Rect</a></h5> <div class="tsd-comment tsd-typography"> <p>The area to fill. Can be omitted to fill the whole image.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="resizecanvas" class="tsd-anchor"></a> <h3>resize<wbr>Canvas</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">resize<wbr>Canvas<span class="tsd-signature-symbol">(</span>__namedParameters<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L365">png-image.ts:365</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Resizes the canvas with while optionally adding padding and cropping regions from the image. Modifies this image and the underlying buffer.</p> </div> <dl class="tsd-comment-tags"> <dt>see</dt> <dd><p>ResizeCanvasArguments</p> </dd> </dl> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>__namedParameters: <span class="tsd-signature-type">object</span></h5> <ul class="tsd-parameters"> <li class="tsd-parameter"> <h5>clip<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Object</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-type">object</span></h5> </li> <li class="tsd-parameter"> <h5>dimensions<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Object</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-type">object</span></h5> </li> <li class="tsd-parameter"> <h5>fill<wbr>Color<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Object</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Object</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Object</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Object</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Object</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-type">object</span></h5> </li> <li class="tsd-parameter"> <h5>offset<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Object</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-type">object</span></h5> </li> </ul> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="rgbaat" class="tsd-anchor"></a> <h3>rgba<wbr>At</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">rgba<wbr>At<span class="tsd-signature-symbol">(</span>x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, y<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../globals.html#colorrgba" class="tsd-signature-type">ColorRGBA</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L339">png-image.ts:339</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Retrieves the color in rgba format, converting from the image&#39;s color format. This will automatically convert from indexed or grayscale images to rgba. If the image&#39;s color format doesn&#39;t provide an alpha channel, <code>255</code> is returned as alpha.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>x: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>The x position of the pixel in the image of which to retrieve the color.</p> </div> </li> <li> <h5>y: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>The y position of the pixel in the image of which to retrieve the color.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="../globals.html#colorrgba" class="tsd-signature-type">ColorRGBA</a></h4> <p>The color at the given pixel in rgba format.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="set" class="tsd-anchor"></a> <h3>set</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">set<span class="tsd-signature-symbol">(</span>color<span class="tsd-signature-symbol">: </span><a href="../globals.html#colorany" class="tsd-signature-type">ColorAny</a>, position<span class="tsd-signature-symbol">: </span><a href="../globals.html#xy" class="tsd-signature-type">XY</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L474">png-image.ts:474</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Set the color of one specific pixel on this image. This will change the underlying data of this image. The change is in-place.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>color: <a href="../globals.html#colorany" class="tsd-signature-type">ColorAny</a></h5> <div class="tsd-comment tsd-typography"> <p>The color with which the area should be filled.</p> </div> </li> <li> <h5>position: <a href="../globals.html#xy" class="tsd-signature-type">XY</a></h5> <div class="tsd-comment tsd-typography"> <p>The position of the pixel to colorize.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="toindex" class="tsd-anchor"></a> <h3>to<wbr>Index</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">to<wbr>Index<span class="tsd-signature-symbol">(</span>x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, y<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L285">png-image.ts:285</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Convert a set of coordinates to index in the buffer.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>x: <span class="tsd-signature-type">number</span></h5> </li> <li> <h5>y: <span class="tsd-signature-type">number</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="toxy" class="tsd-anchor"></a> <h3>toXY</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">toXY<span class="tsd-signature-symbol">(</span>index<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../globals.html#xy" class="tsd-signature-type">XY</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L292">png-image.ts:292</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Convert an index in the buffer to a set of coordinates.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>index: <span class="tsd-signature-type">number</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="../globals.html#xy" class="tsd-signature-type">XY</a></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="write" class="tsd-anchor"></a> <h3>write</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">write<span class="tsd-signature-symbol">(</span>path<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, callback<span class="tsd-signature-symbol">?: </span><a href="../globals.html#writepngfilecallback" class="tsd-signature-type">WritePngFileCallback</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L499">png-image.ts:499</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Will encode this image and write it to the file at the specified path.</p> </div> <dl class="tsd-comment-tags"> <dt>see</dt> <dd><p>writePngFile</p> </dd> </dl> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>path: <span class="tsd-signature-type">string</span></h5> <div class="tsd-comment tsd-typography"> <p>Path to the file to which the encoded PNG should be written.</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> callback: <a href="../globals.html#writepngfilecallback" class="tsd-signature-type">WritePngFileCallback</a></h5> <div class="tsd-comment tsd-typography"> <p>An optional callback to use instead of the Promise API.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span> <span class="tsd-signature-symbol"> | </span> <span class="tsd-signature-type">void</span> </h4> <p>A Promise which resolves once the file is written or <code>undefined</code> if a callback was specified.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="writesync" class="tsd-anchor"></a> <h3>write<wbr>Sync</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">write<wbr>Sync<span class="tsd-signature-symbol">(</span>path<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/Prior99/node-libpng/blob/9e3e190/src/png-image.ts#L514">png-image.ts:514</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Will encode this image and write it to the file at the specified path synchroneously.</p> </div> <dl class="tsd-comment-tags"> <dt>see</dt> <dd><p>writePngFileSync</p> </dd> </dl> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>path: <span class="tsd-signature-type">string</span></h5> <div class="tsd-comment tsd-typography"> <p>Path to the file to which the encoded PNG should be written.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> </section> </div> <div class="col-4 col-menu menu-sticky-wrap menu-highlight"> <nav class="tsd-navigation primary"> <ul> <li class="globals "> <a href="../globals.html"><em>Globals</em></a> </li> </ul> </nav> <nav class="tsd-navigation secondary menu-sticky"> <ul class="before-current"> </ul> <ul class="current"> <li class="current tsd-kind-class"> <a href="pngimage.html" class="tsd-kind-icon">Png<wbr>Image</a> <ul> <li class=" tsd-kind-constructor tsd-parent-kind-class"> <a href="pngimage.html#constructor" class="tsd-kind-icon">constructor</a> </li> <li class=" tsd-kind-property tsd-parent-kind-class"> <a href="pngimage.html#backgroundcolor" class="tsd-kind-icon">background<wbr>Color</a> </li> <li class=" tsd-kind-property tsd-parent-kind-class"> <a href="pngimage.html#bitdepth" class="tsd-kind-icon">bit<wbr>Depth</a> </li> <li class=" tsd-kind-property tsd-parent-kind-class"> <a href="pngimage.html#channels" class="tsd-kind-icon">channels</a> </li> <li class=" tsd-kind-property tsd-parent-kind-class"> <a href="pngimage.html#colortype" class="tsd-kind-icon">color<wbr>Type</a> </li> <li class=" tsd-kind-property tsd-parent-kind-class"> <a href="pngimage.html#data" class="tsd-kind-icon">data</a> </li> <li class=" tsd-kind-property tsd-parent-kind-class"> <a href="pngimage.html#gamma" class="tsd-kind-icon">gamma</a> </li>