Comparing version
@@ -1,1 +0,1 @@ | ||
(function(n,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(n=typeof globalThis<"u"?globalThis:n||self,n.isApng=t())})(this,function(){"use strict";const n=new TextEncoder,t={animationControlChunk:n.encode("acTL"),imageDataChunk:n.encode("IDAT")};function a(e){if(!e||!(typeof Buffer<"u"&&Buffer.isBuffer(e)||e instanceof Uint8Array)||e.length<16||!(e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71&&e[4]===13&&e[5]===10&&e[6]===26&&e[7]===10))return!1;e=e.subarray(8);let o=0,u=0;for(let i=0;i<e.length;i++){if(e[i]!==t.animationControlChunk[o]&&(o=0),e[i]===t.animationControlChunk[o]&&(o++,o===t.animationControlChunk.length))return!0;if(e[i]!==t.imageDataChunk[u]&&(u=0),e[i]===t.imageDataChunk[u]&&(u++,u===t.imageDataChunk.length))return!1}return!1}return a}); | ||
(function(o,r){typeof exports=="object"&&typeof module<"u"?module.exports=r():typeof define=="function"&&define.amd?define(r):(o=typeof globalThis<"u"?globalThis:o||self,o.isApng=r())})(this,function(){"use strict";function o(e){return e.reduce((i,n)=>(i<<8)+n)}function r(e,i,n=4){for(;n>0;)if(n--,e[n]!==i[n])return!1;return!0}const t={SIGNATURE:8,LENGTH:4,TYPE:4,CRC:4},u={signature:[137,80,78,71,13,10,26,10],animationControl:[97,99,84,76],imageData:[73,68,65,84]};function a(e){const i=t.LENGTH+t.TYPE+t.CRC;if(!e||!(e instanceof Uint8Array)||e.length<t.SIGNATURE+i||!r(e,u.signature,t.SIGNATURE))return!1;for(e=e.subarray(t.SIGNATURE);e.length>=i;){const n=e.subarray(t.LENGTH,t.LENGTH+t.TYPE);if(r(n,u.animationControl,t.TYPE))return!0;if(r(n,u.imageData,t.TYPE))return!1;const f=i+o(e.subarray(0,t.LENGTH));e=e.subarray(f)}return!1}return a}); |
{ | ||
"name": "is-apng", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Check if a Buffer/Uint8Array is a APNG (Animated PNG) image", | ||
@@ -70,3 +70,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=14" | ||
"node": ">=18" | ||
}, | ||
@@ -73,0 +73,0 @@ "scripts": { |
# is-apng [![Latest GitHub release][release-image]][release-url] [![Latest NPM version][npm-image]][npm-url] [![Build Status][ci-image]][ci-url] | ||
> Check if a Buffer/Uint8Array is a [Animated PNG / APNG](https://en.wikipedia.org/wiki/APNG) image | ||
> Checks if a Buffer/Uint8Array contains a [Animated PNG / APNG](https://en.wikipedia.org/wiki/APNG) image. | ||
> [!IMPORTANT] | ||
> This is _only_ a quick detect method and does not do full (A)PNG file validation.<br> | ||
> For security and file integrity sensitive operations, use a true (A)PNG validator (see also [specs](https://www.w3.org/TR/png/)). | ||
## Install | ||
@@ -24,2 +28,3 @@ | ||
``` | ||
<sup>_Note: As of version 1.2, Node versions below 18 are not supported._</sup> | ||
@@ -43,3 +48,3 @@ ### Browser <img src="./src/chrome.svg" alt="Chrome" title="Chrome" style="margin-bottom:-0.15em"> <img src="./src/edge.svg" alt="Edge" title="Edge" style="margin-bottom:-0.15em"> <img src="./src/firefox.svg" alt="Firefox" title="Firefox" style="margin-bottom:-0.15em"> <img src="./src/safari.svg" alt="Safari" title="Safari" style="margin-bottom:-0.15em"> <img src="./src/opera.svg" alt="Opera" title="Opera" style="margin-bottom:-0.15em"> | ||
Url for latest version: `https://unpkg.com/is-apng`<br> | ||
Url for specific version: `https://unpkg.com/is-apng@1.1.3/dist/index.js` | ||
Url for specific version: `https://unpkg.com/is-apng@1.2.0/dist/index.js` | ||
@@ -58,3 +63,3 @@ ```html | ||
Url for latest version: `https://unpkg.com/is-apng/dist/index.mjs`<br> | ||
Url for specific version: `https://unpkg.com/is-apng@1.1.3/dist/index.mjs` | ||
Url for specific version: `https://unpkg.com/is-apng@1.2.0/dist/index.mjs` | ||
@@ -61,0 +66,0 @@ ```html |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
13986
2.89%133
3.91%