3.0.1 • Published 3 years ago

is-png v3.0.1

Weekly downloads
1,008,350
License
MIT
Repository
github
Last release
3 years ago

is-png

Check if a Buffer/Uint8Array is a PNG image

Install

$ npm install is-png

Usage

Node.js
import {readChunk} from 'read-chunk';
import isPng from 'is-png';

const buffer = await readChunk('unicorn.png', {length: 8});

isPng(buffer);
//=> true
Browser
import isPng from 'is-png';

const response = await fetch('unicorn.png');
const buffer = await response.arrayBuffer();

isPng(new Uint8Array(buffer));
//=> true

API

isPng(buffer)

Accepts a Buffer (Node.js) or Uint8Array. Returns a boolean of whether buffer is a PNG image.

buffer

The buffer to check. It only needs the first 8 bytes.

Related

  • file-type - Detect the file type of a Buffer/Uint8Array/ArrayBuffer
cc-imagemin-pngquantimagemin-optipng-plusimagemin-pngquant-esunblock-block-save-variables@infinitebrahmanuniverse/nolb-is-p@everything-registry/sub-chunk-1934tauriwms2mbtiless.diandao.orgrollup-plugin-imgminspreadablespreadable-msvite-plugin-image-minifymiaow-png-miniminimum-pngjeuxuiinstall-isms-image-minkenote-npngkenote-upnggrunt-contrib-krakengrunt-kraken-iogrunt-kraken_image_compressiongrunt-imagegrunt-mega-imageimgminifyimgoimagemin-optipngimagemin-optipng-changbaimagemin-optipng-coding-net-vendorimagemin-zopfliimagemin-optipng-progressiveimagemin-optipng-tildenimagemin-optipng-vendorimagemin-oxipngimagemin-oxipng-include-oxipng-binimagemin-pngcrushimagemin-pngoutimagemin-pngquantimagemin-pngquant-chnimagemin-pngquant-cnimagemin-pngquant-coding-net-vendorimagemin-pngquant-envbinimagemin-pngquant-gfwimagemin-upngimagemin-pngquant-mirrorimagemin-pngquant-no-exitimagemin-pngquant-npmmirrorimagemin-pngquant-recursiveimagemin-pngquant-tildenimagemin-pngquant-vendorimagemin-pngquant2imagemin-kitchensinkimagemin-advpngimagemin-cjs-pngquantimagemin-guetzliimagemin-crunchimagemin-envimage-minimizerig-privateinciduntquasgulp-is-imagesh5-templetegulp-imagegulp-image-sans-guetzliimagemin-optipng-interlacednode-zopflipngpngmin-clinucleus-serversindresorhus.jsyellowlabtoolsxy-imagemin-optipngxy-imagemin-pngquantwebsite-screenshot@hkjeffchan/imagemin-pngquant@localnerve/imagemin-optipng@localnerve/imagemin-pngquant@leelen_npm/image-webpack-loader@leelen_npm/vite-plugin-imagemin@mlz/imagemin-optipng@mole-inc/imagemin-optipng@mole-inc/imagemin-pngquant@kaciras-blog/image@quasar/quasar-app-extension-icon-factory@quasar/quasar-app-extension-icon-genie@quasar/icongenie@porky-prince/imagemin-optipng@porky-prince/imagemin-pngout@porky-prince/imagemin-pngquant@snicesoft/imagemin-optipng@snicesoft/imagemin-pngquant@dinamomx/imagemin-optipngendeavorexperiences-imagemin-pngquant@types/is-png@vheemstra/imagemin-avifenc@vheemstra/imagemin-oxipng@walrus/imagemin-pngquant@weus/imagemin-optipng@weus/imagemin-pngquantamlibrary2
3.0.1

3 years ago

3.0.0

4 years ago

2.0.0

6 years ago

1.1.0

8 years ago

1.0.0

10 years ago

0.1.1

11 years ago

0.1.0

11 years ago