// package
is-jpg
type: "module"
// preferences
// replacements (1)
snippet::is-jpg-buffer
Simple or drop-in replacementThis package is no longer necessary. You can check the first three bytes of a buffer against the JPEG file signature to detect if it is a JPEG image.
// example
function isJpg(buf) {
if (!buf || buf.length < 3) return false;
return (
buf[0] === 0xff &&
buf[1] === 0xd8 &&
buf[2] === 0xff
);
}