How to use the is-png function in is-png

To help you get started, we’ve selected a few is-png examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 1j01 / mopaint / src / components / App.js View on Github external
fileReader.onload = () => {
				const arrayBuffer = fileReader.result;
				const uint8Array = new Uint8Array(arrayBuffer);
				if (isPNG(uint8Array)) {
					const metadata = readMetadataSync(uint8Array);
					const formatVersion = metadata["Mopaint Format Version"];
					if (formatVersion) {
						const json = metadata["Program Source"];
						this.loadDocumentFromJSON(json);
					} else {
						// TODO: handle plain image files
						this.showError({
							message:
								"Loading images is not supported yet (other than Mopaint PNG programs)",
						});
					}
				} else if (uint8Array[0] === "{".charCodeAt(0)) {
					const fileReader = new FileReader();
					fileReader.onload = () => {
						this.loadDocumentFromJSON(fileReader.result);

is-png

Check if a Buffer/Uint8Array is a PNG image

MIT
Latest version published 3 years ago

Package Health Score

65 / 100
Full package analysis

Popular is-png functions