This commit is contained in:
2025-11-11 00:04:55 -06:00
parent a76ad41fde
commit 40538eddfd
6405 changed files with 1289756 additions and 0 deletions

76
node_modules/image-type/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,76 @@
import {type Buffer} from 'node:buffer';
export type ImageFileExtension =
| 'jpg'
| 'png'
| 'gif'
| 'webp'
| 'flif'
| 'cr2'
| 'tif'
| 'bmp'
| 'jxr'
| 'psd'
| 'ico'
| 'bpg'
| 'jp2'
| 'jpm'
| 'jpx'
| 'heic'
| 'cur'
| 'dcm'
| 'avif';
export type ImageTypeResult = {
/**
One of the supported [file types](https://github.com/sindresorhus/image-type#supported-file-types).
*/
ext: ImageFileExtension;
/**
The detected [MIME type](https://en.wikipedia.org/wiki/Internet_media_type).
*/
mime: string;
};
/**
Detect the image type of a `Buffer`/`Uint8Array`.
@param input - Input for which to determine the file type. It only needs the first `minimumBytes` amount of bytes.
@example
```
import {readChunk} from 'read-chunk';
import imageType, {minimumBytes} from 'image-type';
const buffer = await readChunk('unicorn.png', {length: minimumBytes});
await imageType(buffer);
//=> {ext: 'png', mime: 'image/png'}
```
@example
```
import https from 'node:https';
import imageType, {minimumBytes} from 'image-type';
const url = 'https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg';
https.get(url, response => {
response.on('readable', () => {
(async () => {
const chunk = response.read(minimumBytes);
response.destroy();
console.log(await imageType(chunk));
//=> {ext: 'jpg', mime: 'image/jpeg'}
})();
});
});
```
*/
export default function imageType(input: Buffer | Uint8Array): Promise<ImageTypeResult | undefined>;
/**
The minimum amount of bytes needed to detect a file type. Currently, it's 4100 bytes, but it can change, so don't hard-code it.
*/
export const minimumBytes: number;

30
node_modules/image-type/index.js generated vendored Normal file
View File

@ -0,0 +1,30 @@
import {fileTypeFromBuffer} from 'file-type';
const imageExtensions = new Set([
'jpg',
'png',
'gif',
'webp',
'flif',
'cr2',
'tif',
'bmp',
'jxr',
'psd',
'ico',
'bpg',
'jp2',
'jpm',
'jpx',
'heic',
'cur',
'dcm',
'avif',
]);
export default async function imageType(input) {
const result = await fileTypeFromBuffer(input);
return imageExtensions.has(result?.ext) && result;
}
export const minimumBytes = 4100;

9
node_modules/image-type/license generated vendored Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

59
node_modules/image-type/package.json generated vendored Normal file
View File

@ -0,0 +1,59 @@
{
"name": "image-type",
"version": "5.2.0",
"description": "Detect the image type of a Buffer/Uint8Array",
"license": "MIT",
"repository": "sindresorhus/image-type",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"types": "./index.d.ts",
"engines": {
"node": ">=14.16"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"image",
"picture",
"photo",
"type",
"detect",
"check",
"is",
"exif",
"binary",
"buffer",
"uint8array",
"png",
"jpg",
"jpeg",
"gif",
"webp",
"tif",
"bmp",
"jxr",
"psd",
"mime"
],
"dependencies": {
"file-type": "^18.1.0"
},
"devDependencies": {
"@types/node": "^18.11.18",
"ava": "^5.1.0",
"read-chunk": "^4.0.3",
"tsd": "^0.25.0",
"xo": "^0.53.1"
}
}

108
node_modules/image-type/readme.md generated vendored Normal file
View File

@ -0,0 +1,108 @@
# image-type
> Detect the image type of a Buffer/Uint8Array
See the [`file-type`](https://github.com/sindresorhus/file-type) module for more file types and a CLI.
## Install
```sh
npm install image-type
```
## Usage
##### Node.js
```js
import {readChunk} from 'read-chunk';
import imageType, {minimumBytes} from 'image-type';
const buffer = await readChunk('unicorn.png', {length: minimumBytes});
await imageType(buffer);
//=> {ext: 'png', mime: 'image/png'}
```
Or from a remote location:
```js
import https from 'node:https';
import imageType, {minimumBytes} from 'image-type';
const url = 'https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg';
https.get(url, response => {
response.on('readable', () => {
(async () => {
const chunk = response.read(minimumBytes);
response.destroy();
console.log(await imageType(chunk));
//=> {ext: 'jpg', mime: 'image/jpeg'}
})();
});
});
```
##### Browser
```js
const xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.png');
xhr.responseType = 'arraybuffer';
xhr.onload = () => {
(async () => {
await imageType(new Uint8Array(this.response));
//=> {ext: 'png', mime: 'image/png'}
})();
};
xhr.send();
```
## API
### imageType(input)
Returns an `Promise<object>` with:
- `ext` - One of the [supported file types](#supported-file-types)
- `mime` - The [MIME type](https://en.wikipedia.org/wiki/Internet_media_type)
Or `undefined` when there is no match.
#### input
Type: `Buffer | Uint8Array`
It only needs the first `minimumBytes` amount of bytes.
### minimumBytes
Type: `number`
The minimum amount of bytes needed to detect a file type. Currently, it's 4100 bytes, but it can change, so don't hardcode it.
## Supported file types
- [`jpg`](https://en.wikipedia.org/wiki/JPEG)
- [`png`](https://en.wikipedia.org/wiki/Portable_Network_Graphics)
- [`gif`](https://en.wikipedia.org/wiki/GIF)
- [`webp`](https://en.wikipedia.org/wiki/WebP)
- [`flif`](https://en.wikipedia.org/wiki/Free_Lossless_Image_Format)
- [`cr2`](https://fileinfo.com/extension/cr2)
- [`tif`](https://en.wikipedia.org/wiki/Tagged_Image_File_Format)
- [`bmp`](https://en.wikipedia.org/wiki/BMP_file_format)
- [`jxr`](https://en.wikipedia.org/wiki/JPEG_XR)
- [`psd`](https://en.wikipedia.org/wiki/Adobe_Photoshop#File_format)
- [`ico`](https://en.wikipedia.org/wiki/ICO_(file_format))
- [`bpg`](https://bellard.org/bpg/)
- [`jp2`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000
- [`jpm`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000
- [`jpx`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000
- [`heic`](https://nokiatech.github.io/heif/technical.html)
- [`cur`](https://en.wikipedia.org/wiki/ICO_(file_format))
- [`dcm`](https://en.wikipedia.org/wiki/DICOM#Data_format) - DICOM Image File
*SVG isn't included as it requires the whole file to be read, but you can get it [here](https://github.com/sindresorhus/is-svg).*