forked from olcxjas-softworks/LarpixClient
big updat:
- update dependencies - add webp support and webp conversion for profile images
This commit is contained in:
parent
19c3dbb42d
commit
95aaaa69ea
244 changed files with 121382 additions and 86 deletions
80
node_modules/image-type/index.d.ts
generated
vendored
Normal file
80
node_modules/image-type/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/// <reference types="node"/>
|
||||
|
||||
declare namespace imageType {
|
||||
type ImageType =
|
||||
| 'jpg'
|
||||
| 'png'
|
||||
| 'gif'
|
||||
| 'webp'
|
||||
| 'flif'
|
||||
| 'cr2'
|
||||
| 'tif'
|
||||
| 'bmp'
|
||||
| 'jxr'
|
||||
| 'psd'
|
||||
| 'ico'
|
||||
| 'bpg'
|
||||
| 'jp2'
|
||||
| 'jpm'
|
||||
| 'jpx'
|
||||
| 'heic'
|
||||
| 'cur'
|
||||
| 'dcm';
|
||||
|
||||
interface ImageTypeResult {
|
||||
/**
|
||||
One of the supported [file types](https://github.com/sindresorhus/image-type#supported-file-types).
|
||||
*/
|
||||
ext: ImageType;
|
||||
|
||||
/**
|
||||
The detected [MIME type](https://en.wikipedia.org/wiki/Internet_media_type).
|
||||
*/
|
||||
mime: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare const imageType: {
|
||||
/**
|
||||
Detect the image type of a `Buffer`/`Uint8Array`.
|
||||
|
||||
@param input - Input to examine to determine the file type. It only needs the first `.minimumBytes` bytes.
|
||||
|
||||
@example
|
||||
```
|
||||
import readChunk = require('read-chunk');
|
||||
import imageType = require('image-type');
|
||||
|
||||
const buffer = readChunk.sync('unicorn.png', 0, 12);
|
||||
|
||||
imageType(buffer);
|
||||
//=> {ext: 'png', mime: 'image/png'}
|
||||
|
||||
|
||||
// Or from a remote location:
|
||||
import * as http from 'http';
|
||||
|
||||
const url = 'https://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif';
|
||||
|
||||
http.get(url, response => {
|
||||
response.on('readable', () => {
|
||||
const chunk = response.read(imageType.minimumBytes);
|
||||
response.destroy();
|
||||
console.log(imageType(chunk));
|
||||
//=> {ext: 'gif', mime: 'image/gif'}
|
||||
});
|
||||
});
|
||||
```
|
||||
*/
|
||||
(input: Buffer | Uint8Array): imageType.ImageTypeResult | null;
|
||||
|
||||
/**
|
||||
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.
|
||||
*/
|
||||
readonly minimumBytes: number;
|
||||
|
||||
// TODO: Remove this for the next major release
|
||||
default: typeof imageType;
|
||||
};
|
||||
|
||||
export = imageType;
|
||||
34
node_modules/image-type/index.js
generated
vendored
Normal file
34
node_modules/image-type/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
'use strict';
|
||||
const fileType = require('file-type');
|
||||
|
||||
const imageExts = new Set([
|
||||
'jpg',
|
||||
'png',
|
||||
'gif',
|
||||
'webp',
|
||||
'flif',
|
||||
'cr2',
|
||||
'tif',
|
||||
'bmp',
|
||||
'jxr',
|
||||
'psd',
|
||||
'ico',
|
||||
'bpg',
|
||||
'jp2',
|
||||
'jpm',
|
||||
'jpx',
|
||||
'heic',
|
||||
'cur',
|
||||
'dcm'
|
||||
]);
|
||||
|
||||
const imageType = input => {
|
||||
const ret = fileType(input);
|
||||
return imageExts.has(ret && ret.ext) ? ret : null;
|
||||
};
|
||||
|
||||
module.exports = imageType;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = imageType;
|
||||
|
||||
Object.defineProperty(imageType, 'minimumBytes', {value: fileType.minimumBytes});
|
||||
9
node_modules/image-type/license
generated
vendored
Normal file
9
node_modules/image-type/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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.
|
||||
57
node_modules/image-type/package.json
generated
vendored
Normal file
57
node_modules/image-type/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"name": "image-type",
|
||||
"version": "4.1.0",
|
||||
"description": "Detect the image type of a Buffer/Uint8Array",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/image-type",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"image",
|
||||
"img",
|
||||
"pic",
|
||||
"picture",
|
||||
"photo",
|
||||
"type",
|
||||
"detect",
|
||||
"check",
|
||||
"is",
|
||||
"exif",
|
||||
"binary",
|
||||
"buffer",
|
||||
"uint8array",
|
||||
"png",
|
||||
"jpg",
|
||||
"jpeg",
|
||||
"gif",
|
||||
"webp",
|
||||
"tif",
|
||||
"bmp",
|
||||
"jxr",
|
||||
"psd",
|
||||
"mime"
|
||||
],
|
||||
"dependencies": {
|
||||
"file-type": "^10.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^11.13.0",
|
||||
"ava": "^1.4.1",
|
||||
"read-chunk": "^3.2.0",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
113
node_modules/image-type/readme.md
generated
vendored
Normal file
113
node_modules/image-type/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
# image-type [](https://travis-ci.org/sindresorhus/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
|
||||
|
||||
```
|
||||
$ npm install image-type
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
##### Node.js
|
||||
|
||||
```js
|
||||
const readChunk = require('read-chunk');
|
||||
const imageType = require('image-type');
|
||||
|
||||
const buffer = readChunk.sync('unicorn.png', 0, 12);
|
||||
|
||||
imageType(buffer);
|
||||
//=> {ext: 'png', mime: 'image/png'}
|
||||
```
|
||||
|
||||
Or from a remote location:
|
||||
|
||||
```js
|
||||
const http = require('http');
|
||||
const imageType = require('image-type');
|
||||
|
||||
const url = 'https://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif';
|
||||
|
||||
http.get(url, response => {
|
||||
response.on('readable', () => {
|
||||
const chunk = response.read(imageType.minimumBytes);
|
||||
response.destroy();
|
||||
console.log(imageType(chunk));
|
||||
//=> {ext: 'gif', mime: 'image/gif'}
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
##### Browser
|
||||
|
||||
```js
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'unicorn.png');
|
||||
xhr.responseType = 'arraybuffer';
|
||||
|
||||
xhr.onload = () => {
|
||||
imageType(new Uint8Array(this.response));
|
||||
//=> {ext: 'png', mime: 'image/png'}
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### imageType(input)
|
||||
|
||||
Returns an `Object` with:
|
||||
|
||||
- `ext` - One of the [supported file types](#supported-file-types)
|
||||
- `mime` - The [MIME type](http://en.wikipedia.org/wiki/Internet_media_type)
|
||||
|
||||
Or `null` when there is no match.
|
||||
|
||||
#### input
|
||||
|
||||
Type: `Buffer | Uint8Array`
|
||||
|
||||
It only needs the first `.minimumBytes` bytes.
|
||||
|
||||
### imageType.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).*
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
Loading…
Add table
Add a link
Reference in a new issue