Latest repo

This commit is contained in:
Marc
2025-06-02 16:42:16 +00:00
parent 53ddf1a329
commit cde5fae175
27907 changed files with 3875388 additions and 1 deletions

21
node_modules/jay-peg/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Diego Muracciole <diegomuracciole@gmail.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.

120
node_modules/jay-peg/README.md generated vendored Normal file
View File

@@ -0,0 +1,120 @@
# jay-peg
<a href="https://www.npmjs.com/package/jay-peg">
<img src="https://img.shields.io/npm/v/jay-peg.svg" />
</a>
<a href="https://github.com/diegomura/jay-peg/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/diegomura/jay-peg.svg" />
</a>
<a href="https://github.com/prettier/prettier">
<img src="https://img.shields.io/badge/styled_with-prettier-ff69b4.svg" />
</a>
## Overview
A blazing-fast and compact JavaScript library dedicated to efficiently decoding JPEG images.
## Installation
Using npm:
```bash
npm install jay-peg
```
Using yarn:
```bash
yarn add jay-peg
```
## Usage
Use the `decoder` providing a JPEG data buffer as input.
```javascript
import JPEG from 'jay-peg';
const jpegBuffer = /* your JPEG buffer here */;
const imageMarkers = JPEG.decoder(jpegBuffer);
console.log(imageMarkers);
```
## Example Output
The output consists of a structured array of image markers:
```javascript
[
{
type: 65496,
name: "SOI",
},
{
type: 65505,
name: "EXIF",
length: 16382,
identifier: "Exif\x00\x00",
entries: [Object],
},
{
type: 65499,
name: "DAC",
length: 132,
tables: [[Object], [Object]],
},
// ... and so forth
{
type: 65497,
name: "EOI",
},
];
```
## API
### `decoder(buffer: Buffer | Uint8Array): Array<ImageMarker>`
The `decoder` function accepts a JPEG buffer as its sole argument and returns an array of image markers.
#### Parameters
- `buffer`: A Buffer or Uint8Array containing the JPEG image data.
#### Returns
An array of objects representing various markers found in the JPEG image.
### `ImageMarker`
Each `ImageMarker` object in the output array adheres to the following structure:
- `type` (Number): The marker type.
- `name` (String): The marker name.
- `length` (Number): The length of the marker data.
- Additional properties specific to certain marker types.
## Performance
Performance is a key focus of `jay-peg`. 4 sizes of images were benchmarked:
- `small`: 300×150, 8KB image
- `medium`: 800×600, 70KB image
- `large`: 1920×1080, 332KB image
- `huge`: 2448×3264, 2.2MB image
For each of these, the decoding speed was measured as follows:
```
Benchmarked: small: x 13,393 ops/sec ±4.77% (96 runs sampled)
Benchmarked: medium: x 12,894 ops/sec ±0.10% (99 runs sampled)
Benchmarked: large: x 9,241 ops/sec ±0.25% (99 runs sampled)
Benchmarked: huge: x 2,672 ops/sec ±0.12% (100 runs sampled)
```
_Measures were taken in an MacBook Air 2024, Apple M3 w/16GB of RAM._
## License
`jay-peg` is released under the [MIT License](LICENSE)

515
node_modules/jay-peg/dist/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,515 @@
var $gXNCa$restructure = require("restructure");
function $parcel$defineInteropFlag(a) {
Object.defineProperty(a, '__esModule', {value: true, configurable: true});
}
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$defineInteropFlag(module.exports);
$parcel$export(module.exports, "default", () => $4fa36e821943b400$export$2e2bcd8739ae039);
const $aa341883af0ae85e$var$DACTable = new $gXNCa$restructure.Struct({
identifier: new $gXNCa$restructure.Buffer(1),
value: new $gXNCa$restructure.Buffer(1)
});
const $aa341883af0ae85e$var$DACMarker = {
name: ()=>"DAC",
length: $gXNCa$restructure.uint16be,
tables: new $gXNCa$restructure.Array($aa341883af0ae85e$var$DACTable, (parent)=>parent.length / 2)
};
var $aa341883af0ae85e$export$2e2bcd8739ae039 = $aa341883af0ae85e$var$DACMarker;
const $bd10db122e664297$export$a91b4a1eede2f230 = (array, offset)=>{
return array[offset];
};
const $bd10db122e664297$export$8b37dabc2dc78838 = (array, offset)=>{
return array[offset] << 8 | array[offset + 1];
};
const $bd10db122e664297$export$a549f6d34e76d37a = (array, offset)=>{
return array[offset] | array[offset + 1] << 8;
};
const $bd10db122e664297$export$cfaef8ed399428b0 = (array, offset)=>{
return $bd10db122e664297$export$89308d455f98d9(array, offset) >>> 0;
};
const $bd10db122e664297$export$d3485ee83d66d723 = (array, offset)=>{
return $bd10db122e664297$export$41469b9fa4aaddde(array, offset) >>> 0;
};
const $bd10db122e664297$export$d4d5806f7c45a793 = (uint8Array)=>{
return Array.from(uint8Array, (byte)=>byte.toString(16).padStart(2, "0")).join("");
};
const $bd10db122e664297$var$decoder = new TextDecoder("utf-8");
const $bd10db122e664297$export$f3924c82a04770ee = (uint8Array)=>{
return $bd10db122e664297$var$decoder.decode(uint8Array);
};
const $bd10db122e664297$export$deffdc216bdfb4c = (arrays)=>{
const totalLength = arrays.reduce((length, arr)=>length + arr.length, 0);
const concatenatedArray = new Uint8Array(totalLength);
let offset = 0;
arrays.forEach((arr)=>{
concatenatedArray.set(arr, offset);
offset += arr.length;
});
return concatenatedArray;
};
const $bd10db122e664297$export$89308d455f98d9 = (array, offset)=>{
return array[offset] << 24 | array[offset + 1] << 16 | array[offset + 2] << 8 | array[offset + 3];
};
const $bd10db122e664297$export$41469b9fa4aaddde = (array, offset)=>{
return array[offset] | array[offset + 1] << 8 | array[offset + 2] << 16 | array[offset + 3] << 24;
};
class $876ae4d13cf7aa4e$var$HuffmanTableElements {
decode(stream, parent) {
const tables = {};
let buffer = stream.buffer.slice(stream.pos, stream.pos + parent.length - 2);
while(buffer.length > 0){
let offset = 1;
const elements = [];
const identifier = (0, $bd10db122e664297$export$a91b4a1eede2f230)(buffer, 0);
const lengths = buffer.slice(offset, offset + 16);
offset += 16;
for (const length of lengths){
elements.push(buffer.slice(offset, offset + length));
offset += length;
}
buffer = buffer.slice(offset);
tables[identifier] = (0, $bd10db122e664297$export$deffdc216bdfb4c)(elements);
}
stream.pos += parent.length - 2;
return tables;
}
}
const $876ae4d13cf7aa4e$var$DefineHuffmanTableMarker = {
name: ()=>"DHT",
length: $gXNCa$restructure.uint16be,
tables: new $876ae4d13cf7aa4e$var$HuffmanTableElements()
};
var $876ae4d13cf7aa4e$export$2e2bcd8739ae039 = $876ae4d13cf7aa4e$var$DefineHuffmanTableMarker;
const $a90ba18fc4ccf97a$var$DQTMarker = {
name: ()=>"DQT",
length: $gXNCa$restructure.uint16be,
tables: new $gXNCa$restructure.Array(new $gXNCa$restructure.Struct({
identifier: new $gXNCa$restructure.Buffer(1),
data: new $gXNCa$restructure.Buffer(64)
}), (parent)=>(parent.length - 2) / 65)
};
var $a90ba18fc4ccf97a$export$2e2bcd8739ae039 = $a90ba18fc4ccf97a$var$DQTMarker;
const $38e4486858db78cb$var$DRIMarker = {
name: ()=>"DRI",
length: $gXNCa$restructure.uint16be,
restartInterval: $gXNCa$restructure.uint16be
};
var $38e4486858db78cb$export$2e2bcd8739ae039 = $38e4486858db78cb$var$DRIMarker;
const $c2766d9e4fc88dcb$var$EndOfImageMarker = {
name: ()=>"EOI",
afterEOI: new $gXNCa$restructure.Reserved($gXNCa$restructure.uint8, Infinity)
};
var $c2766d9e4fc88dcb$export$2e2bcd8739ae039 = $c2766d9e4fc88dcb$var$EndOfImageMarker;
const $0b53e5b7c7fe341c$var$tags = {
ifd: {
"010e": "imageDescription",
"010f": "make",
"011a": "xResolution",
"011b": "yResolution",
"011c": "planarConfiguration",
"012d": "transferFunction",
"013b": "artist",
"013e": "whitePoint",
"013f": "primaryChromaticities",
"0100": "imageWidth",
"0101": "imageHeight",
"0102": "bitsPerSample",
"0103": "compression",
"0106": "photometricInterpretation",
"0110": "model",
"0111": "stripOffsets",
"0112": "orientation",
"0115": "samplesPerPixel",
"0116": "rowsPerStrip",
"0117": "stripByteCounts",
"0128": "resolutionUnit",
"0131": "software",
"0132": "dateTime",
"0201": "jpegInterchangeFormat",
"0202": "jpegInterchangeFormatLength",
"0211": "ycbCrCoefficients",
"0212": "ycbCrSubSampling",
"0213": "ycbCrPositioning",
"0214": "referenceBlackWhite",
"829a": "exposureTime",
"829d": "fNumber",
"920a": "focalLength",
"927c": "makerNote",
8298: "copyright",
8769: "exifIFDPointer",
8822: "exposureProgram",
8824: "spectralSensitivity",
8825: "gpsInfoIFDPointer",
8827: "photographicSensitivity",
8828: "oecf",
8830: "sensitivityType",
8831: "standardOutputSensitivity",
8832: "recommendedExposureIndex",
8833: "isoSpeed",
8834: "isoSpeedLatitudeyyy",
8835: "isoSpeedLatitudezzz",
9000: "exifVersion",
9003: "dateTimeOriginal",
9004: "dateTimeDigitized",
9101: "componentsConfiguration",
9102: "compressedBitsPerPixel",
9201: "shutterSpeedValue",
9202: "apertureValue",
9203: "brightnessValue",
9204: "exposureBiasValue",
9205: "maxApertureValue",
9206: "subjectDistance",
9207: "meteringMode",
9208: "lightSource",
9209: "flash",
9214: "subjectArea",
9286: "userComment",
9290: "subSecTime",
9291: "subSecTimeOriginal",
9292: "subSecTimeDigitized",
a000: "flashpixVersion",
a001: "colorSpace",
a002: "pixelXDimension",
a003: "pixelYDimension",
a004: "relatedSoundFile",
a005: "interoperabilityIFDPointer",
a20b: "flashEnergy",
a20c: "spatialFrequencyResponse",
a20e: "focalPlaneXResolution",
a20f: "focalPlaneYResolution",
a40a: "sharpness",
a40b: "deviceSettingDescription",
a40c: "subjectDistanceRange",
a210: "focalPlaneResolutionUnit",
a214: "subjectLocation",
a215: "exposureIndex",
a217: "sensingMethod",
a300: "fileSource",
a301: "sceneType",
a302: "cfaPattern",
a401: "customRendered",
a402: "exposureMode",
a403: "whiteBalance",
a404: "digitalZoomRatio",
a405: "focalLengthIn35mmFilm",
a406: "sceneCaptureType",
a407: "gainControl",
a408: "contrast",
a409: "saturation",
a420: "imageUniqueID",
a430: "cameraOwnerName",
a431: "bodySerialNumber",
a432: "lensSpecification",
a433: "lensMake",
a434: "lensModel",
a435: "lensSerialNumber",
a500: "gamma"
},
gps: {
"0000": "gpsVersionID",
"0001": "gpsLatitudeRef",
"0002": "gpsLatitude",
"0003": "gpsLongitudeRef",
"0004": "gpsLongitude",
"0005": "gpsAltitudeRef",
"0006": "gpsAltitude",
"0007": "gpsTimeStamp",
"0008": "gpsSatellites",
"0009": "gpsStatus",
"000a": "gpsMeasureMode",
"000b": "gpsDOP",
"000c": "gpsSpeedRef",
"000d": "gpsSpeed",
"000e": "gpsTrackRef",
"000f": "gpsTrack",
"0010": "gpsImgDirectionRef",
"0011": "gpsImgDirection",
"0012": "gpsMapDatum",
"0013": "gpsDestLatitudeRef",
"0014": "gpsDestLatitude",
"0015": "gpsDestLongitudeRef",
"0016": "gpsDestLongitude",
"0017": "gpsDestBearingRef",
"0018": "gpsDestBearing",
"0019": "gpsDestDistanceRef",
"001a": "gpsDestDistance",
"001b": "gpsProcessingMethod",
"001c": "gpsAreaInformation",
"001d": "gpsDateStamp",
"001e": "gpsDifferential",
"001f": "gpsHPositioningError"
}
};
class $0b53e5b7c7fe341c$var$IDFEntries {
constructor(bigEndian){
this.bigEndian = bigEndian;
this.bytes = [
0,
1,
1,
2,
4,
8,
1,
1,
2,
4,
8,
4,
8
];
}
_getTagValue(dataValue, dataFormat, componentsNumber) {
switch(dataFormat){
case 2:
return dataValue.toString("ascii").replace(/\0+$/, "");
case 129:
return dataValue.toString("utf8").replace(/\0+$/, "");
case 7:
return "0x" + dataValue.toString("hex");
default:
return this._getTagValueForNumericalData(dataValue, dataFormat, componentsNumber);
}
}
_getTagValueForNumericalData(dataValue, dataFormat, componentsNumber) {
const tagValue = [];
const componentsBytes = this.bytes[dataFormat];
for(let i = 0; i < componentsNumber; i += 1)tagValue.push(this._getSingleTagValueForNumericalData(dataValue, dataFormat, i * componentsBytes));
return tagValue.length === 1 ? tagValue[0] : tagValue;
}
_getSingleTagValueForNumericalData(dataValue, dataFormat, pos) {
const uint16 = (pos)=>this.bigEndian ? (0, $bd10db122e664297$export$8b37dabc2dc78838)(dataValue, pos) : (0, $bd10db122e664297$export$a549f6d34e76d37a)(dataValue, pos);
const uint32 = (pos)=>this.bigEndian ? (0, $bd10db122e664297$export$cfaef8ed399428b0)(dataValue, pos) : (0, $bd10db122e664297$export$d3485ee83d66d723)(dataValue, pos);
const int32 = (pos)=>this.bigEndian ? (0, $bd10db122e664297$export$89308d455f98d9)(dataValue, pos) : (0, $bd10db122e664297$export$41469b9fa4aaddde)(dataValue, pos);
switch(dataFormat){
case 1:
return (0, $bd10db122e664297$export$a91b4a1eede2f230)(dataValue, pos);
case 3:
return uint16(pos);
case 4:
return uint32(pos);
case 5:
return uint32(pos) / uint32(pos + 4);
case 9:
return int32(pos);
case 10:
return int32(pos) / int32(pos + 4);
}
}
_decodeIDFEntries(buffer, tags, offset, log = false) {
let pos = 2 + offset;
const entries = {};
const uint16 = (pos)=>this.bigEndian ? (0, $bd10db122e664297$export$8b37dabc2dc78838)(buffer, pos) : (0, $bd10db122e664297$export$a549f6d34e76d37a)(buffer, pos);
const uint32 = (pos)=>this.bigEndian ? (0, $bd10db122e664297$export$cfaef8ed399428b0)(buffer, pos) : (0, $bd10db122e664297$export$d3485ee83d66d723)(buffer, pos);
const numberOfEntries = uint16(offset);
for(let i = 0; i < numberOfEntries; i++){
const tagAddress = buffer.slice(pos, pos + 2);
const dataFormat = uint16(pos + 2);
const componentsNumber = uint32(pos + 4);
const componentsBytes = this.bytes[dataFormat];
const dataLength = componentsNumber * componentsBytes;
let dataValue = buffer.slice(pos + 8, pos + 12);
if (dataLength > 4) {
const dataOffset = this.bigEndian ? (0, $bd10db122e664297$export$cfaef8ed399428b0)(dataValue, 0) : (0, $bd10db122e664297$export$d3485ee83d66d723)(dataValue, 0);
dataValue = buffer.slice(dataOffset, dataOffset + dataLength);
}
const tagValue = this._getTagValue(dataValue, dataFormat, componentsNumber);
const tagNumber = this.bigEndian ? (0, $bd10db122e664297$export$d4d5806f7c45a793)(tagAddress) : (0, $bd10db122e664297$export$d4d5806f7c45a793)(tagAddress.reverse());
const tagName = tags[tagNumber];
entries[tagName] = tagValue;
pos += 12;
}
return entries;
}
decode(stream, parent) {
const buffer = stream.buffer.slice(stream.pos - 8);
const offsetToFirstIFD = parent.offsetToFirstIFD;
if (offsetToFirstIFD > buffer.length) {
stream.pos += parent.parent.length - 16;
return {};
}
const entries = this._decodeIDFEntries(buffer, $0b53e5b7c7fe341c$var$tags.ifd, offsetToFirstIFD);
const { exifIFDPointer: exifIFDPointer, gpsInfoIFDPointer: gpsInfoIFDPointer } = entries;
if (exifIFDPointer) entries.subExif = this._decodeIDFEntries(buffer, $0b53e5b7c7fe341c$var$tags.ifd, exifIFDPointer);
if (gpsInfoIFDPointer) {
const gps = gpsInfoIFDPointer;
entries.gpsInfo = this._decodeIDFEntries(buffer, $0b53e5b7c7fe341c$var$tags.gps, gps, true);
}
stream.pos += parent.parent.length - 16;
return entries;
}
}
const $0b53e5b7c7fe341c$var$IFDData = (bigEndian)=>{
const uint16 = bigEndian ? $gXNCa$restructure.uint16be : $gXNCa$restructure.uint16le;
const uint32 = bigEndian ? $gXNCa$restructure.uint32be : $gXNCa$restructure.uint32le;
return new $gXNCa$restructure.Struct({
fortyTwo: uint16,
offsetToFirstIFD: uint32,
entries: new $0b53e5b7c7fe341c$var$IDFEntries(bigEndian)
});
};
class $0b53e5b7c7fe341c$var$TIFFHeader {
decode(stream, parent) {
const byteOrder = (0, $bd10db122e664297$export$f3924c82a04770ee)(stream.buffer.slice(stream.pos, stream.pos + 2));
const bigEndian = byteOrder === "MM";
stream.pos += 2;
const data = $0b53e5b7c7fe341c$var$IFDData(bigEndian).decode(stream, parent);
return data.entries;
}
}
const $0b53e5b7c7fe341c$var$EXIFMarker = {
name: ()=>"EXIF",
length: $gXNCa$restructure.uint16be,
identifier: new $gXNCa$restructure.String(6),
entries: new $0b53e5b7c7fe341c$var$TIFFHeader()
};
var $0b53e5b7c7fe341c$export$2e2bcd8739ae039 = $0b53e5b7c7fe341c$var$EXIFMarker;
const $04bcf19210df7b64$var$JFIFMarker = {
name: ()=>"JFIF",
length: $gXNCa$restructure.uint16be,
identifier: new $gXNCa$restructure.String(5),
version: $gXNCa$restructure.uint16be,
units: $gXNCa$restructure.uint8,
xDensity: $gXNCa$restructure.uint16be,
yDensity: $gXNCa$restructure.uint16be,
thumbnailWidth: $gXNCa$restructure.uint8,
thumbnailHeight: $gXNCa$restructure.uint8
};
var $04bcf19210df7b64$export$2e2bcd8739ae039 = $04bcf19210df7b64$var$JFIFMarker;
class $2e255b533ff4fcbb$var$ImageData {
decode(stream) {
const buffer = stream.buffer.slice(stream.pos);
let length = 0;
let i = buffer.indexOf(0xff);
while(i !== -1){
length = i;
const nextByte = buffer[length + 1];
const comesRestart = nextByte >= 0xd0 && nextByte <= 0xd7;
if (nextByte !== 0x00 && !comesRestart) break;
i = buffer.indexOf(0xff, i + 1);
}
stream.pos += length;
return buffer.slice(0, length);
}
}
const $2e255b533ff4fcbb$var$SOSComponentSpecification = new $gXNCa$restructure.Struct({
scanComponentSelector: $gXNCa$restructure.uint8,
entropyCodingTable: new $gXNCa$restructure.Buffer(1)
});
const $2e255b533ff4fcbb$var$SOSMarker = {
name: ()=>"SOS",
length: $gXNCa$restructure.uint16be,
numberOfImageComponents: $gXNCa$restructure.uint8,
componentSpecifications: new $gXNCa$restructure.Array($2e255b533ff4fcbb$var$SOSComponentSpecification, (parent)=>parent.numberOfImageComponents),
startOfSpectral: $gXNCa$restructure.uint8,
endOfSpectral: $gXNCa$restructure.uint8,
successiveApproximationBit: new $gXNCa$restructure.Buffer(1),
data: new $2e255b533ff4fcbb$var$ImageData()
};
var $2e255b533ff4fcbb$export$2e2bcd8739ae039 = $2e255b533ff4fcbb$var$SOSMarker;
const $0765cace26fd2550$var$FrameColorComponent = new $gXNCa$restructure.Struct({
id: $gXNCa$restructure.uint8,
samplingFactors: $gXNCa$restructure.uint8,
quantizationTableId: $gXNCa$restructure.uint8
});
const $0765cace26fd2550$var$StartOfFrameMarker = {
name: ()=>"SOF",
length: $gXNCa$restructure.uint16be,
precision: $gXNCa$restructure.uint8,
height: $gXNCa$restructure.uint16be,
width: $gXNCa$restructure.uint16be,
numberOfComponents: $gXNCa$restructure.uint8,
components: new $gXNCa$restructure.Array($0765cace26fd2550$var$FrameColorComponent, (parent)=>parent.numberOfComponents)
};
var $0765cace26fd2550$export$2e2bcd8739ae039 = $0765cace26fd2550$var$StartOfFrameMarker;
const $5cb7f9bcb7bda090$var$StartOfImageMarker = {
name: ()=>"SOI"
};
var $5cb7f9bcb7bda090$export$2e2bcd8739ae039 = $5cb7f9bcb7bda090$var$StartOfImageMarker;
const $4fa36e821943b400$var$UnknownMarker = {
length: $gXNCa$restructure.uint16be,
buf: new $gXNCa$restructure.Buffer((parent)=>parent.length - 2)
};
const $4fa36e821943b400$var$unknownMarkers = Array(63).fill(0).reduce((acc, v, i)=>({
...acc,
[i + 0xffc0]: $4fa36e821943b400$var$UnknownMarker
}), {});
const $4fa36e821943b400$var$Marker = new $gXNCa$restructure.VersionedStruct($gXNCa$restructure.uint16be, {
...$4fa36e821943b400$var$unknownMarkers,
0xffc0: (0, $0765cace26fd2550$export$2e2bcd8739ae039),
0xffc1: (0, $0765cace26fd2550$export$2e2bcd8739ae039),
0xffc2: (0, $0765cace26fd2550$export$2e2bcd8739ae039),
0xffc3: (0, $0765cace26fd2550$export$2e2bcd8739ae039),
0xffc4: (0, $876ae4d13cf7aa4e$export$2e2bcd8739ae039),
0xffc5: (0, $0765cace26fd2550$export$2e2bcd8739ae039),
0xffc6: (0, $0765cace26fd2550$export$2e2bcd8739ae039),
0xffc7: (0, $0765cace26fd2550$export$2e2bcd8739ae039),
0xffc9: (0, $0765cace26fd2550$export$2e2bcd8739ae039),
0xffca: (0, $0765cace26fd2550$export$2e2bcd8739ae039),
0xffcb: (0, $0765cace26fd2550$export$2e2bcd8739ae039),
0xffcc: (0, $aa341883af0ae85e$export$2e2bcd8739ae039),
0xffcd: (0, $0765cace26fd2550$export$2e2bcd8739ae039),
0xffce: (0, $0765cace26fd2550$export$2e2bcd8739ae039),
0xffcf: (0, $0765cace26fd2550$export$2e2bcd8739ae039),
0xffd8: (0, $5cb7f9bcb7bda090$export$2e2bcd8739ae039),
0xffd9: (0, $c2766d9e4fc88dcb$export$2e2bcd8739ae039),
0xffda: (0, $2e255b533ff4fcbb$export$2e2bcd8739ae039),
0xffdb: (0, $a90ba18fc4ccf97a$export$2e2bcd8739ae039),
0xffdd: (0, $38e4486858db78cb$export$2e2bcd8739ae039),
0xffe0: (0, $04bcf19210df7b64$export$2e2bcd8739ae039),
0xffe1: (0, $0b53e5b7c7fe341c$export$2e2bcd8739ae039)
});
const $4fa36e821943b400$var$JPEG = new $gXNCa$restructure.Array($4fa36e821943b400$var$Marker);
const $4fa36e821943b400$var$decode = (buffer)=>{
const markers = $4fa36e821943b400$var$JPEG.fromBuffer(buffer);
return markers.map(({ version: version, ...rest })=>({
type: version,
...rest
}));
};
var $4fa36e821943b400$export$2e2bcd8739ae039 = {
decode: $4fa36e821943b400$var$decode
};
//# sourceMappingURL=index.cjs.map

1
node_modules/jay-peg/dist/index.cjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

45
node_modules/jay-peg/package.json generated vendored Normal file
View File

@@ -0,0 +1,45 @@
{
"name": "jay-peg",
"description": "Performant JPEG decoder",
"version": "1.1.1",
"type": "module",
"license": "MIT",
"main": "./dist/index.cjs",
"module": "./src/index.js",
"source": "./src/index.js",
"exports": {
"import": "./src/index.js",
"require": "./dist/index.cjs"
},
"targets": {
"module": false
},
"keywords": [
"binary",
"jpeg",
"decode"
],
"files": [
"src",
"dist",
"LICENSE",
"README.md"
],
"scripts": {
"test": "vitest",
"benchmark": "node ./benchmark",
"format": "yarn prettier . --write",
"build": "parcel build",
"prepublishOnly": "parcel build"
},
"dependencies": {
"restructure": "^3.0.0"
},
"devDependencies": {
"benchmark": "^2.1.4",
"colors": "^1.4.0",
"parcel": "^2.11.0",
"prettier": "3.2.4",
"vitest": "^1.2.2"
}
}

56
node_modules/jay-peg/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
import * as r from "restructure";
import DACMarker from "./markers/dac.js";
import DefineHuffmanTableMarker from "./markers/dht.js";
import DQTMarker from "./markers/dqt.js";
import DRIMarker from "./markers/dri.js";
import EndOfImageMarker from "./markers/eoi.js";
import EXIFMarker from "./markers/exif.js";
import JFIFMarker from "./markers/jfif.js";
import SOSMarker from "./markers/sos.js";
import StartOfFrameMarker from "./markers/sof.js";
import StartOfImageMarker from "./markers/soi.js";
const UnknownMarker = {
length: r.uint16be,
buf: new r.Buffer((parent) => parent.length - 2),
};
const unknownMarkers = Array(63)
.fill(0)
.reduce((acc, v, i) => ({ ...acc, [i + 0xffc0]: UnknownMarker }), {});
const Marker = new r.VersionedStruct(r.uint16be, {
...unknownMarkers,
0xffc0: StartOfFrameMarker,
0xffc1: StartOfFrameMarker,
0xffc2: StartOfFrameMarker,
0xffc3: StartOfFrameMarker,
0xffc4: DefineHuffmanTableMarker,
0xffc5: StartOfFrameMarker,
0xffc6: StartOfFrameMarker,
0xffc7: StartOfFrameMarker,
0xffc9: StartOfFrameMarker,
0xffca: StartOfFrameMarker,
0xffcb: StartOfFrameMarker,
0xffcc: DACMarker,
0xffcd: StartOfFrameMarker,
0xffce: StartOfFrameMarker,
0xffcf: StartOfFrameMarker,
0xffd8: StartOfImageMarker,
0xffd9: EndOfImageMarker,
0xffda: SOSMarker,
0xffdb: DQTMarker,
0xffdd: DRIMarker,
0xffe0: JFIFMarker,
0xffe1: EXIFMarker,
});
const JPEG = new r.Array(Marker);
const decode = (buffer) => {
const markers = JPEG.fromBuffer(buffer);
return markers.map(({ version, ...rest }) => ({ type: version, ...rest }));
};
export default { decode };

14
node_modules/jay-peg/src/markers/dac.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import * as r from "restructure";
const DACTable = new r.Struct({
identifier: new r.Buffer(1),
value: new r.Buffer(1),
});
const DACMarker = {
name: () => "DAC",
length: r.uint16be,
tables: new r.Array(DACTable, (parent) => parent.length / 2),
};
export default DACMarker;

44
node_modules/jay-peg/src/markers/dht.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
import * as r from "restructure";
import { concatenateUint8Arrays, readUInt8 } from "./utils.js";
class HuffmanTableElements {
decode(stream, parent) {
const tables = {};
let buffer = stream.buffer.slice(
stream.pos,
stream.pos + parent.length - 2,
);
while (buffer.length > 0) {
let offset = 1;
const elements = [];
const identifier = readUInt8(buffer, 0);
const lengths = buffer.slice(offset, offset + 16);
offset += 16;
for (const length of lengths) {
elements.push(buffer.slice(offset, offset + length));
offset += length;
}
buffer = buffer.slice(offset);
tables[identifier] = concatenateUint8Arrays(elements);
}
stream.pos += parent.length - 2;
return tables;
}
}
const DefineHuffmanTableMarker = {
name: () => "DHT",
length: r.uint16be,
tables: new HuffmanTableElements(),
};
export default DefineHuffmanTableMarker;

15
node_modules/jay-peg/src/markers/dqt.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import * as r from "restructure";
const DQTMarker = {
name: () => "DQT",
length: r.uint16be,
tables: new r.Array(
new r.Struct({
identifier: new r.Buffer(1),
data: new r.Buffer(64),
}),
(parent) => (parent.length - 2) / 65,
),
};
export default DQTMarker;

9
node_modules/jay-peg/src/markers/dri.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import * as r from "restructure";
const DRIMarker = {
name: () => "DRI",
length: r.uint16be,
restartInterval: r.uint16be,
};
export default DRIMarker;

8
node_modules/jay-peg/src/markers/eoi.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import * as r from "restructure";
const EndOfImageMarker = {
name: () => "EOI",
afterEOI: new r.Reserved(r.uint8, Infinity),
};
export default EndOfImageMarker;

327
node_modules/jay-peg/src/markers/exif.js generated vendored Normal file
View File

@@ -0,0 +1,327 @@
import * as r from "restructure";
import {
readUInt8,
readUInt16BE,
readUInt16LE,
readUInt32BE,
readUInt32LE,
uint8ArrayToHexString,
uint8ArrayToString,
readInt32BE,
readInt32LE,
} from "./utils.js";
const tags = {
ifd: {
"010e": "imageDescription",
"010f": "make",
"011a": "xResolution",
"011b": "yResolution",
"011c": "planarConfiguration",
"012d": "transferFunction",
"013b": "artist",
"013e": "whitePoint",
"013f": "primaryChromaticities",
"0100": "imageWidth",
"0101": "imageHeight",
"0102": "bitsPerSample",
"0103": "compression",
"0106": "photometricInterpretation",
"0110": "model",
"0111": "stripOffsets",
"0112": "orientation",
"0115": "samplesPerPixel",
"0116": "rowsPerStrip",
"0117": "stripByteCounts",
"0128": "resolutionUnit",
"0131": "software",
"0132": "dateTime",
"0201": "jpegInterchangeFormat",
"0202": "jpegInterchangeFormatLength",
"0211": "ycbCrCoefficients",
"0212": "ycbCrSubSampling",
"0213": "ycbCrPositioning",
"0214": "referenceBlackWhite",
"829a": "exposureTime",
"829d": "fNumber",
"920a": "focalLength",
"927c": "makerNote",
8298: "copyright",
8769: "exifIFDPointer",
8822: "exposureProgram",
8824: "spectralSensitivity",
8825: "gpsInfoIFDPointer",
8827: "photographicSensitivity",
8828: "oecf",
8830: "sensitivityType",
8831: "standardOutputSensitivity",
8832: "recommendedExposureIndex",
8833: "isoSpeed",
8834: "isoSpeedLatitudeyyy",
8835: "isoSpeedLatitudezzz",
9000: "exifVersion",
9003: "dateTimeOriginal",
9004: "dateTimeDigitized",
9101: "componentsConfiguration",
9102: "compressedBitsPerPixel",
9201: "shutterSpeedValue",
9202: "apertureValue",
9203: "brightnessValue",
9204: "exposureBiasValue",
9205: "maxApertureValue",
9206: "subjectDistance",
9207: "meteringMode",
9208: "lightSource",
9209: "flash",
9214: "subjectArea",
9286: "userComment",
9290: "subSecTime",
9291: "subSecTimeOriginal",
9292: "subSecTimeDigitized",
a000: "flashpixVersion",
a001: "colorSpace",
a002: "pixelXDimension",
a003: "pixelYDimension",
a004: "relatedSoundFile",
a005: "interoperabilityIFDPointer",
a20b: "flashEnergy",
a20c: "spatialFrequencyResponse",
a20e: "focalPlaneXResolution",
a20f: "focalPlaneYResolution",
a40a: "sharpness",
a40b: "deviceSettingDescription",
a40c: "subjectDistanceRange",
a210: "focalPlaneResolutionUnit",
a214: "subjectLocation",
a215: "exposureIndex",
a217: "sensingMethod",
a300: "fileSource",
a301: "sceneType",
a302: "cfaPattern",
a401: "customRendered",
a402: "exposureMode",
a403: "whiteBalance",
a404: "digitalZoomRatio",
a405: "focalLengthIn35mmFilm",
a406: "sceneCaptureType",
a407: "gainControl",
a408: "contrast",
a409: "saturation",
a420: "imageUniqueID",
a430: "cameraOwnerName",
a431: "bodySerialNumber",
a432: "lensSpecification",
a433: "lensMake",
a434: "lensModel",
a435: "lensSerialNumber",
a500: "gamma",
},
gps: {
"0000": "gpsVersionID",
"0001": "gpsLatitudeRef",
"0002": "gpsLatitude",
"0003": "gpsLongitudeRef",
"0004": "gpsLongitude",
"0005": "gpsAltitudeRef",
"0006": "gpsAltitude",
"0007": "gpsTimeStamp",
"0008": "gpsSatellites",
"0009": "gpsStatus",
"000a": "gpsMeasureMode",
"000b": "gpsDOP",
"000c": "gpsSpeedRef",
"000d": "gpsSpeed",
"000e": "gpsTrackRef",
"000f": "gpsTrack",
"0010": "gpsImgDirectionRef",
"0011": "gpsImgDirection",
"0012": "gpsMapDatum",
"0013": "gpsDestLatitudeRef",
"0014": "gpsDestLatitude",
"0015": "gpsDestLongitudeRef",
"0016": "gpsDestLongitude",
"0017": "gpsDestBearingRef",
"0018": "gpsDestBearing",
"0019": "gpsDestDistanceRef",
"001a": "gpsDestDistance",
"001b": "gpsProcessingMethod",
"001c": "gpsAreaInformation",
"001d": "gpsDateStamp",
"001e": "gpsDifferential",
"001f": "gpsHPositioningError",
},
};
class IDFEntries {
constructor(bigEndian) {
this.bigEndian = bigEndian;
this.bytes = [0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8];
}
_getTagValue(dataValue, dataFormat, componentsNumber) {
switch (dataFormat) {
case 2:
return dataValue.toString("ascii").replace(/\0+$/, "");
case 129:
return dataValue.toString("utf8").replace(/\0+$/, "");
case 7:
return "0x" + dataValue.toString("hex");
default:
return this._getTagValueForNumericalData(dataValue, dataFormat, componentsNumber);
}
}
_getTagValueForNumericalData(dataValue, dataFormat, componentsNumber) {
const tagValue = [];
const componentsBytes = this.bytes[dataFormat];
for (let i = 0; i < componentsNumber; i += 1) {
tagValue.push(this._getSingleTagValueForNumericalData(dataValue, dataFormat, i * componentsBytes));
}
return tagValue.length === 1 ? tagValue[0] : tagValue;
}
_getSingleTagValueForNumericalData(dataValue, dataFormat, pos) {
const uint16 = (pos) =>
this.bigEndian
? readUInt16BE(dataValue, pos)
: readUInt16LE(dataValue, pos);
const uint32 = (pos) =>
this.bigEndian
? readUInt32BE(dataValue, pos)
: readUInt32LE(dataValue, pos);
const int32 = (pos) =>
this.bigEndian
? readInt32BE(dataValue, pos)
: readInt32LE(dataValue, pos);
switch (dataFormat) {
case 1:
return readUInt8(dataValue, pos)
case 3:
return uint16(pos);
case 4:
return uint32(pos);
case 5:
return uint32(pos) / uint32(pos + 4);
case 9:
return int32(pos);
case 10: {
return int32(pos) / int32(pos + 4);
}
}
}
_decodeIDFEntries(buffer, tags, offset, log = false) {
let pos = 2 + offset;
const entries = {};
const uint16 = (pos) =>
this.bigEndian ? readUInt16BE(buffer, pos) : readUInt16LE(buffer, pos);
const uint32 = (pos) =>
this.bigEndian ? readUInt32BE(buffer, pos) : readUInt32LE(buffer, pos);
const numberOfEntries = uint16(offset);
for (let i = 0; i < numberOfEntries; i++) {
const tagAddress = buffer.slice(pos, pos + 2);
const dataFormat = uint16(pos + 2);
const componentsNumber = uint32(pos + 4);
const componentsBytes = this.bytes[dataFormat];
const dataLength = componentsNumber * componentsBytes;
let dataValue = buffer.slice(pos + 8, pos + 12);
if (dataLength > 4) {
const dataOffset = this.bigEndian
? readUInt32BE(dataValue, 0)
: readUInt32LE(dataValue, 0);
dataValue = buffer.slice(dataOffset, dataOffset + dataLength);
}
const tagValue = this._getTagValue(dataValue, dataFormat, componentsNumber);
const tagNumber = this.bigEndian
? uint8ArrayToHexString(tagAddress)
: uint8ArrayToHexString(tagAddress.reverse());
const tagName = tags[tagNumber];
entries[tagName] = tagValue;
pos += 12;
}
return entries;
}
decode(stream, parent) {
const buffer = stream.buffer.slice(stream.pos - 8);
const offsetToFirstIFD = parent.offsetToFirstIFD;
if (offsetToFirstIFD > buffer.length) {
stream.pos += parent.parent.length - 16;
return {};
}
const entries = this._decodeIDFEntries(buffer, tags.ifd, offsetToFirstIFD);
const { exifIFDPointer, gpsInfoIFDPointer } = entries;
if (exifIFDPointer) {
entries.subExif = this._decodeIDFEntries(
buffer,
tags.ifd,
exifIFDPointer,
);
}
if (gpsInfoIFDPointer) {
const gps = gpsInfoIFDPointer;
entries.gpsInfo = this._decodeIDFEntries(buffer, tags.gps, gps, true);
}
stream.pos += parent.parent.length - 16;
return entries;
}
}
const IFDData = (bigEndian) => {
const uint16 = bigEndian ? r.uint16be : r.uint16le;
const uint32 = bigEndian ? r.uint32be : r.uint32le;
return new r.Struct({
fortyTwo: uint16,
offsetToFirstIFD: uint32,
entries: new IDFEntries(bigEndian),
});
};
class TIFFHeader {
decode(stream, parent) {
const byteOrder = uint8ArrayToString(
stream.buffer.slice(stream.pos, stream.pos + 2),
);
const bigEndian = byteOrder === "MM";
stream.pos += 2;
const data = IFDData(bigEndian).decode(stream, parent);
return data.entries;
}
}
const EXIFMarker = {
name: () => "EXIF",
length: r.uint16be,
identifier: new r.String(6),
entries: new TIFFHeader(),
};
export default EXIFMarker;

15
node_modules/jay-peg/src/markers/jfif.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import * as r from "restructure";
const JFIFMarker = {
name: () => "JFIF",
length: r.uint16be,
identifier: new r.String(5),
version: r.uint16be,
units: r.uint8,
xDensity: r.uint16be,
yDensity: r.uint16be,
thumbnailWidth: r.uint8,
thumbnailHeight: r.uint8,
};
export default JFIFMarker;

22
node_modules/jay-peg/src/markers/sof.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import * as r from "restructure";
const FrameColorComponent = new r.Struct({
id: r.uint8,
samplingFactors: r.uint8,
quantizationTableId: r.uint8,
});
const StartOfFrameMarker = {
name: () => "SOF",
length: r.uint16be,
precision: r.uint8,
height: r.uint16be,
width: r.uint16be,
numberOfComponents: r.uint8,
components: new r.Array(
FrameColorComponent,
(parent) => parent.numberOfComponents,
),
};
export default StartOfFrameMarker;

5
node_modules/jay-peg/src/markers/soi.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
const StartOfImageMarker = {
name: () => "SOI",
};
export default StartOfImageMarker;

46
node_modules/jay-peg/src/markers/sos.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
import * as r from "restructure";
class ImageData {
decode(stream) {
const buffer = stream.buffer.slice(stream.pos);
let length = 0;
let i = buffer.indexOf(0xff);
while (i !== -1) {
length = i;
const nextByte = buffer[length + 1];
const comesRestart = nextByte >= 0xd0 && nextByte <= 0xd7;
if (nextByte !== 0x00 && !comesRestart) break;
i = buffer.indexOf(0xff, i + 1);
}
stream.pos += length;
return buffer.slice(0, length);
}
}
const SOSComponentSpecification = new r.Struct({
scanComponentSelector: r.uint8,
entropyCodingTable: new r.Buffer(1),
});
const SOSMarker = {
name: () => "SOS",
length: r.uint16be,
numberOfImageComponents: r.uint8,
componentSpecifications: new r.Array(
SOSComponentSpecification,
(parent) => parent.numberOfImageComponents,
),
startOfSpectral: r.uint8,
endOfSpectral: r.uint8,
successiveApproximationBit: new r.Buffer(1),
data: new ImageData(),
};
export default SOSMarker;

63
node_modules/jay-peg/src/markers/utils.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
export const readUInt8 = (array, offset) => {
return array[offset];
};
export const readUInt16BE = (array, offset) => {
return (array[offset] << 8) | array[offset + 1];
};
export const readUInt16LE = (array, offset) => {
return array[offset] | (array[offset + 1] << 8);
};
export const readUInt32BE = (array, offset) => {
return readInt32BE(array, offset) >>> 0;
};
export const readUInt32LE = (array, offset) => {
return readInt32LE(array, offset) >>> 0;
};
export const uint8ArrayToHexString = (uint8Array) => {
return Array.from(uint8Array, (byte) =>
byte.toString(16).padStart(2, "0"),
).join("");
};
const decoder = new TextDecoder("utf-8");
export const uint8ArrayToString = (uint8Array) => {
return decoder.decode(uint8Array);
};
export const concatenateUint8Arrays = (arrays) => {
const totalLength = arrays.reduce((length, arr) => length + arr.length, 0);
const concatenatedArray = new Uint8Array(totalLength);
let offset = 0;
arrays.forEach((arr) => {
concatenatedArray.set(arr, offset);
offset += arr.length;
});
return concatenatedArray;
};
export const readInt32BE = (array, offset) => {
return (
(array[offset] << 24) |
(array[offset + 1] << 16) |
(array[offset + 2] << 8) |
array[offset + 3]
);
};
export const readInt32LE = (array, offset) => {
return (
array[offset] |
(array[offset + 1] << 8) |
(array[offset + 2] << 16) |
(array[offset + 3] << 24)
);
};