@biongff/vizarr 1.1.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -0
- package/dist/biongff-vizarr.cjs.js +1 -0
- package/dist/biongff-vizarr.es.js +9 -0
- package/dist/blosc-CeItQ6qj.cjs +17 -0
- package/dist/blosc-DaK8KnI4.js +719 -0
- package/dist/chunk-INHXZS53-DiyuLb3Z.js +14 -0
- package/dist/chunk-INHXZS53-z3BpFH8p.cjs +1 -0
- package/dist/deflate-DzrO3E-1.cjs +1 -0
- package/dist/deflate-Q4iCMMBa.js +10 -0
- package/dist/index-3CiumG5V.js +53876 -0
- package/dist/index-Ckhcz4QQ.cjs +3815 -0
- package/dist/index.d.ts +119 -0
- package/dist/jpeg-BdEIe3QG.js +533 -0
- package/dist/jpeg-DFzBPcur.cjs +1 -0
- package/dist/jpeg2k-1tnzEScI.js +24 -0
- package/dist/jpeg2k-CcF6vCxI.cjs +1 -0
- package/dist/lerc-35FtXNGP.cjs +1 -0
- package/dist/lerc-B6qlOBE2.js +1039 -0
- package/dist/lz4-CssV0LoA.js +643 -0
- package/dist/lz4-PFaIsPAh.cjs +15 -0
- package/dist/lzw-CeXp5T9s.js +84 -0
- package/dist/lzw-DnHvgKbO.cjs +1 -0
- package/dist/packbits-CAZoMCQq.js +24 -0
- package/dist/packbits-DwdUAwAt.cjs +1 -0
- package/dist/pako.esm-Bx5X36Wo.js +1074 -0
- package/dist/pako.esm-DZC2QrbJ.cjs +1 -0
- package/dist/raw-BB450wdT.cjs +1 -0
- package/dist/raw-oTi55tWo.js +9 -0
- package/dist/ref-Bd0nPTvp.js +196 -0
- package/dist/ref-CIxavIn6.cjs +1 -0
- package/dist/webimage-66a9vFf5.cjs +1 -0
- package/dist/webimage-CKRNzqyG.js +19 -0
- package/dist/zstd-Cqadn9HA.js +610 -0
- package/dist/zstd-_xUhkGOV.cjs +15 -0
- package/package.json +35 -21
- package/.gitattributes +0 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -32
- package/.github/ISSUE_TEMPLATE/documentation_update.md +0 -16
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -19
- package/.github/ISSUE_TEMPLATE/maintenance.md +0 -19
- package/.github/ISSUE_TEMPLATE/optimisation_request.md +0 -23
- package/.github/ISSUE_TEMPLATE/support_request.md +0 -25
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -21
- package/.github/dependabot.yml +0 -13
- package/.github/workflows/deploy.yml +0 -56
- package/.github/workflows/npm-publish-dev.yml +0 -49
- package/.github/workflows/npm-publish.yml +0 -42
- package/.github/workflows/release.yml +0 -37
- package/.github/workflows/test.yml +0 -21
- package/.releaserc.json +0 -29
- package/CHANGELOG.md +0 -70
- package/CITATION.cff +0 -56
- package/CONTRIBUTING.md +0 -82
- package/README.md +0 -85
- package/assets/favicon.ico +0 -0
- package/assets/favicon.png +0 -0
- package/assets/logo-wide.png +0 -0
- package/assets/logo-wide.svg +0 -60
- package/assets/logo.png +0 -0
- package/assets/logo.svg +0 -36
- package/assets/robots.txt +0 -3
- package/assets/screenshot.png +0 -0
- package/biome.json +0 -34
- package/index.html +0 -24
- package/main.ts +0 -52
- package/patches/@vivjs__loaders@0.17.2.patch +0 -13
- package/python/.python-version +0 -1
- package/python/README.md +0 -14
- package/python/Untitled.ipynb +0 -40
- package/python/deno.json +0 -22
- package/python/notebooks/IDR_example.ipynb +0 -86
- package/python/notebooks/README.md +0 -35
- package/python/notebooks/create_fixture.py +0 -72
- package/python/notebooks/getting_started.ipynb +0 -217
- package/python/notebooks/mandelbrot.ipynb +0 -211
- package/python/notebooks/spatial_transformations.ipynb +0 -139
- package/python/pyproject.toml +0 -18
- package/python/src/vizarr/__init__.py +0 -10
- package/python/src/vizarr/_widget.js +0 -113
- package/python/src/vizarr/_widget.py +0 -67
- package/python/uv.lock +0 -2495
- package/src/ZarrPixelSource.ts +0 -182
- package/src/codecs/jpeg2k.ts +0 -22
- package/src/codecs/register.ts +0 -2
- package/src/components/LayerController/AcquisitionController.tsx +0 -46
- package/src/components/LayerController/AddChannelButton.tsx +0 -122
- package/src/components/LayerController/AxisOptions.tsx +0 -93
- package/src/components/LayerController/AxisSlider.tsx +0 -86
- package/src/components/LayerController/AxisSliders.tsx +0 -29
- package/src/components/LayerController/ChannelController.tsx +0 -84
- package/src/components/LayerController/ChannelOptions.tsx +0 -183
- package/src/components/LayerController/ColorPalette.tsx +0 -40
- package/src/components/LayerController/Content.tsx +0 -71
- package/src/components/LayerController/Header.tsx +0 -48
- package/src/components/LayerController/Labels.tsx +0 -73
- package/src/components/LayerController/LayerFitToViewportButton.tsx +0 -43
- package/src/components/LayerController/LayerVisibilityButton.tsx +0 -32
- package/src/components/LayerController/OpacitySlider.tsx +0 -25
- package/src/components/LayerController/index.tsx +0 -42
- package/src/components/Menu.tsx +0 -54
- package/src/components/Viewer.tsx +0 -136
- package/src/hooks.ts +0 -29
- package/src/index.tsx +0 -138
- package/src/io.ts +0 -276
- package/src/layers/grid-layer.ts +0 -214
- package/src/layers/label-layer.ts +0 -446
- package/src/layers/viv-layers.ts +0 -55
- package/src/lru-store.ts +0 -57
- package/src/ome.ts +0 -388
- package/src/state.ts +0 -202
- package/src/theme.ts +0 -80
- package/src/types.ts +0 -112
- package/src/utils.ts +0 -663
- package/tsconfig.json +0 -14
- package/vite.config.js +0 -47
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import { Layer } from 'deck.gl';
|
|
3
|
+
import { PrimitiveAtom } from 'jotai';
|
|
4
|
+
import * as React_2 from 'react';
|
|
5
|
+
import { Theme } from '@mui/material';
|
|
6
|
+
import { version } from '../../package.json';
|
|
7
|
+
import type * as zarr from 'zarrita';
|
|
8
|
+
|
|
9
|
+
declare interface BaseConfig {
|
|
10
|
+
source: string | zarr.Readable;
|
|
11
|
+
axis_labels?: string[];
|
|
12
|
+
name?: string;
|
|
13
|
+
colormap?: string;
|
|
14
|
+
opacity?: number;
|
|
15
|
+
acquisition?: string;
|
|
16
|
+
model_matrix?: string | number[];
|
|
17
|
+
coordinateSystem?: string;
|
|
18
|
+
onClick?: (e: unknown) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare function createViewer(element: HTMLElement, options?: {
|
|
22
|
+
menuOpen?: boolean;
|
|
23
|
+
}): Promise<VizarrViewer>;
|
|
24
|
+
|
|
25
|
+
declare type Events = {
|
|
26
|
+
viewStateChange: ViewState;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export declare type ImageLayerConfig = MultichannelConfig | SingleChannelConfig;
|
|
30
|
+
|
|
31
|
+
declare interface MultichannelConfig extends BaseConfig {
|
|
32
|
+
colors?: string[];
|
|
33
|
+
channel_axis?: number;
|
|
34
|
+
contrast_limits?: [min: number, max: number][];
|
|
35
|
+
names?: string[];
|
|
36
|
+
visibilities?: boolean[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare interface SingleChannelConfig extends BaseConfig {
|
|
40
|
+
color?: string;
|
|
41
|
+
contrast_limits?: [min: number, max: number];
|
|
42
|
+
visibility?: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export declare const theme: Theme;
|
|
46
|
+
|
|
47
|
+
export declare function useViewState(): [ViewState | null, (update: ViewState | ((prev: ViewState | null) => ViewState | null) | null) => void];
|
|
48
|
+
|
|
49
|
+
export { version }
|
|
50
|
+
|
|
51
|
+
/** Viewer state snapshot exposed to the host application via onViewerStateChange. */
|
|
52
|
+
export declare interface ViewerInfo {
|
|
53
|
+
sourceUrl: string;
|
|
54
|
+
imageBounds: {
|
|
55
|
+
xMin: number;
|
|
56
|
+
yMin: number;
|
|
57
|
+
xMax: number;
|
|
58
|
+
yMax: number;
|
|
59
|
+
spatialUnit: string;
|
|
60
|
+
} | null;
|
|
61
|
+
zInfo: {
|
|
62
|
+
zValue: number;
|
|
63
|
+
zMax: number;
|
|
64
|
+
} | null;
|
|
65
|
+
tInfo: {
|
|
66
|
+
tValue: number;
|
|
67
|
+
tMax: number;
|
|
68
|
+
} | null;
|
|
69
|
+
viewport: ViewportSize | null;
|
|
70
|
+
setViewState: (vs: ViewState) => void;
|
|
71
|
+
setZSlice: (z: number) => void;
|
|
72
|
+
setTSlice: (t: number) => void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Plain-data snapshot of the deck.gl canvas dimensions. */
|
|
76
|
+
export declare interface ViewportSize {
|
|
77
|
+
width: number;
|
|
78
|
+
height: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export declare interface ViewState {
|
|
82
|
+
/**Level of zoom */
|
|
83
|
+
zoom: number;
|
|
84
|
+
/** Coordinates to center the view state on */
|
|
85
|
+
target: [number, number];
|
|
86
|
+
width?: number;
|
|
87
|
+
height?: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export declare const ViewStateContext: React_2.Context<PrimitiveAtom<ViewState | null> | null>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
*Component to render source images
|
|
94
|
+
*/
|
|
95
|
+
export declare function Vizarr({ children, ...props }: VizarrViewerProps): default_2.JSX.Element;
|
|
96
|
+
|
|
97
|
+
export declare interface VizarrViewer {
|
|
98
|
+
addImage(config: ImageLayerConfig): void;
|
|
99
|
+
setViewState(viewState: ViewState): void;
|
|
100
|
+
on<E extends keyof Events>(event: E, cb: (data: Events[E]) => void): void;
|
|
101
|
+
destroy(): void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export declare interface VizarrViewerProps {
|
|
105
|
+
/** Source image urls*/
|
|
106
|
+
sources?: string[];
|
|
107
|
+
/** View state of the viewer*/
|
|
108
|
+
viewState?: ViewState;
|
|
109
|
+
/** Callback to execute side effects when view state changes */
|
|
110
|
+
onViewStateChange?: (viewState: ViewState) => void;
|
|
111
|
+
onViewerStateChange?: (info: ViewerInfo) => void;
|
|
112
|
+
additionalLayers?: Layer[];
|
|
113
|
+
pluginCursor?: string;
|
|
114
|
+
onPluginClick?: (coordinate: [number, number]) => boolean;
|
|
115
|
+
onPluginHover?: (coordinate: [number, number] | null) => void;
|
|
116
|
+
children?: default_2.ReactNode;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { }
|
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
import { B as re } from "./index-3CiumG5V.js";
|
|
2
|
+
const O = new Int32Array([
|
|
3
|
+
0,
|
|
4
|
+
1,
|
|
5
|
+
8,
|
|
6
|
+
16,
|
|
7
|
+
9,
|
|
8
|
+
2,
|
|
9
|
+
3,
|
|
10
|
+
10,
|
|
11
|
+
17,
|
|
12
|
+
24,
|
|
13
|
+
32,
|
|
14
|
+
25,
|
|
15
|
+
18,
|
|
16
|
+
11,
|
|
17
|
+
4,
|
|
18
|
+
5,
|
|
19
|
+
12,
|
|
20
|
+
19,
|
|
21
|
+
26,
|
|
22
|
+
33,
|
|
23
|
+
40,
|
|
24
|
+
48,
|
|
25
|
+
41,
|
|
26
|
+
34,
|
|
27
|
+
27,
|
|
28
|
+
20,
|
|
29
|
+
13,
|
|
30
|
+
6,
|
|
31
|
+
7,
|
|
32
|
+
14,
|
|
33
|
+
21,
|
|
34
|
+
28,
|
|
35
|
+
35,
|
|
36
|
+
42,
|
|
37
|
+
49,
|
|
38
|
+
56,
|
|
39
|
+
57,
|
|
40
|
+
50,
|
|
41
|
+
43,
|
|
42
|
+
36,
|
|
43
|
+
29,
|
|
44
|
+
22,
|
|
45
|
+
15,
|
|
46
|
+
23,
|
|
47
|
+
30,
|
|
48
|
+
37,
|
|
49
|
+
44,
|
|
50
|
+
51,
|
|
51
|
+
58,
|
|
52
|
+
59,
|
|
53
|
+
52,
|
|
54
|
+
45,
|
|
55
|
+
38,
|
|
56
|
+
31,
|
|
57
|
+
39,
|
|
58
|
+
46,
|
|
59
|
+
53,
|
|
60
|
+
60,
|
|
61
|
+
61,
|
|
62
|
+
54,
|
|
63
|
+
47,
|
|
64
|
+
55,
|
|
65
|
+
62,
|
|
66
|
+
63
|
|
67
|
+
]), Y = 4017, Z = 799, $ = 3406, N = 2276, Q = 1567, W = 3784, R = 5793, K = 2896;
|
|
68
|
+
function ne(q, l) {
|
|
69
|
+
let o = 0;
|
|
70
|
+
const u = [];
|
|
71
|
+
let T = 16;
|
|
72
|
+
for (; T > 0 && !q[T - 1]; )
|
|
73
|
+
--T;
|
|
74
|
+
u.push({ children: [], index: 0 });
|
|
75
|
+
let w = u[0], C;
|
|
76
|
+
for (let t = 0; t < T; t++) {
|
|
77
|
+
for (let h = 0; h < q[t]; h++) {
|
|
78
|
+
for (w = u.pop(), w.children[w.index] = l[o]; w.index > 0; )
|
|
79
|
+
w = u.pop();
|
|
80
|
+
for (w.index++, u.push(w); u.length <= t; )
|
|
81
|
+
u.push(C = { children: [], index: 0 }), w.children[w.index] = C.children, w = C;
|
|
82
|
+
o++;
|
|
83
|
+
}
|
|
84
|
+
t + 1 < T && (u.push(C = { children: [], index: 0 }), w.children[w.index] = C.children, w = C);
|
|
85
|
+
}
|
|
86
|
+
return u[0].children;
|
|
87
|
+
}
|
|
88
|
+
function ce(q, l, o, u, T, w, C, t, h) {
|
|
89
|
+
const { mcusPerLine: F, progressive: c } = o, r = l;
|
|
90
|
+
let b = l, i = 0, d = 0;
|
|
91
|
+
function m() {
|
|
92
|
+
if (d > 0)
|
|
93
|
+
return d--, i >> d & 1;
|
|
94
|
+
if (i = q[b++], i === 255) {
|
|
95
|
+
const a = q[b++];
|
|
96
|
+
if (a)
|
|
97
|
+
throw new Error(`unexpected marker: ${(i << 8 | a).toString(16)}`);
|
|
98
|
+
}
|
|
99
|
+
return d = 7, i >>> 7;
|
|
100
|
+
}
|
|
101
|
+
function x(a) {
|
|
102
|
+
let f = a, p;
|
|
103
|
+
for (; (p = m()) !== null; ) {
|
|
104
|
+
if (f = f[p], typeof f == "number")
|
|
105
|
+
return f;
|
|
106
|
+
if (typeof f != "object")
|
|
107
|
+
throw new Error("invalid huffman sequence");
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
function E(a) {
|
|
112
|
+
let f = a, p = 0;
|
|
113
|
+
for (; f > 0; ) {
|
|
114
|
+
const L = m();
|
|
115
|
+
if (L === null)
|
|
116
|
+
return;
|
|
117
|
+
p = p << 1 | L, --f;
|
|
118
|
+
}
|
|
119
|
+
return p;
|
|
120
|
+
}
|
|
121
|
+
function k(a) {
|
|
122
|
+
const f = E(a);
|
|
123
|
+
return f >= 1 << a - 1 ? f : f + (-1 << a) + 1;
|
|
124
|
+
}
|
|
125
|
+
function A(a, f) {
|
|
126
|
+
const p = x(a.huffmanTableDC), L = p === 0 ? 0 : k(p);
|
|
127
|
+
a.pred += L, f[0] = a.pred;
|
|
128
|
+
let D = 1;
|
|
129
|
+
for (; D < 64; ) {
|
|
130
|
+
const P = x(a.huffmanTableAC), y = P & 15, S = P >> 4;
|
|
131
|
+
if (y === 0) {
|
|
132
|
+
if (S < 15)
|
|
133
|
+
break;
|
|
134
|
+
D += 16;
|
|
135
|
+
} else {
|
|
136
|
+
D += S;
|
|
137
|
+
const I = O[D];
|
|
138
|
+
f[I] = k(y), D++;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function v(a, f) {
|
|
143
|
+
const p = x(a.huffmanTableDC), L = p === 0 ? 0 : k(p) << h;
|
|
144
|
+
a.pred += L, f[0] = a.pred;
|
|
145
|
+
}
|
|
146
|
+
function s(a, f) {
|
|
147
|
+
f[0] |= m() << h;
|
|
148
|
+
}
|
|
149
|
+
let n = 0;
|
|
150
|
+
function g(a, f) {
|
|
151
|
+
if (n > 0) {
|
|
152
|
+
n--;
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
let p = w;
|
|
156
|
+
const L = C;
|
|
157
|
+
for (; p <= L; ) {
|
|
158
|
+
const D = x(a.huffmanTableAC), P = D & 15, y = D >> 4;
|
|
159
|
+
if (P === 0) {
|
|
160
|
+
if (y < 15) {
|
|
161
|
+
n = E(y) + (1 << y) - 1;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
p += 16;
|
|
165
|
+
} else {
|
|
166
|
+
p += y;
|
|
167
|
+
const S = O[p];
|
|
168
|
+
f[S] = k(P) * (1 << h), p++;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
let e = 0, _;
|
|
173
|
+
function te(a, f) {
|
|
174
|
+
let p = w;
|
|
175
|
+
const L = C;
|
|
176
|
+
let D = 0;
|
|
177
|
+
for (; p <= L; ) {
|
|
178
|
+
const P = O[p], y = f[P] < 0 ? -1 : 1;
|
|
179
|
+
switch (e) {
|
|
180
|
+
case 0: {
|
|
181
|
+
const S = x(a.huffmanTableAC), I = S & 15;
|
|
182
|
+
if (D = S >> 4, I === 0)
|
|
183
|
+
D < 15 ? (n = E(D) + (1 << D), e = 4) : (D = 16, e = 1);
|
|
184
|
+
else {
|
|
185
|
+
if (I !== 1)
|
|
186
|
+
throw new Error("invalid ACn encoding");
|
|
187
|
+
_ = k(I), e = D ? 2 : 3;
|
|
188
|
+
}
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
case 1:
|
|
192
|
+
// skipping r zero items
|
|
193
|
+
case 2:
|
|
194
|
+
f[P] ? f[P] += (m() << h) * y : (D--, D === 0 && (e = e === 2 ? 3 : 0));
|
|
195
|
+
break;
|
|
196
|
+
case 3:
|
|
197
|
+
f[P] ? f[P] += (m() << h) * y : (f[P] = _ << h, e = 0);
|
|
198
|
+
break;
|
|
199
|
+
case 4:
|
|
200
|
+
f[P] && (f[P] += (m() << h) * y);
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
p++;
|
|
204
|
+
}
|
|
205
|
+
e === 4 && (n--, n === 0 && (e = 0));
|
|
206
|
+
}
|
|
207
|
+
function se(a, f, p, L, D) {
|
|
208
|
+
const P = p / F | 0, y = p % F, S = P * a.v + L, I = y * a.h + D;
|
|
209
|
+
f(a, a.blocks[S][I]);
|
|
210
|
+
}
|
|
211
|
+
function oe(a, f, p) {
|
|
212
|
+
const L = p / a.blocksPerLine | 0, D = p % a.blocksPerLine;
|
|
213
|
+
f(a, a.blocks[L][D]);
|
|
214
|
+
}
|
|
215
|
+
const V = u.length;
|
|
216
|
+
let U, j, G, X, B, H;
|
|
217
|
+
c ? w === 0 ? H = t === 0 ? v : s : H = t === 0 ? g : te : H = A;
|
|
218
|
+
let M = 0, z, J;
|
|
219
|
+
V === 1 ? J = u[0].blocksPerLine * u[0].blocksPerColumn : J = F * o.mcusPerColumn;
|
|
220
|
+
const ee = T || J;
|
|
221
|
+
for (; M < J; ) {
|
|
222
|
+
for (j = 0; j < V; j++)
|
|
223
|
+
u[j].pred = 0;
|
|
224
|
+
if (n = 0, V === 1)
|
|
225
|
+
for (U = u[0], B = 0; B < ee; B++)
|
|
226
|
+
oe(U, H, M), M++;
|
|
227
|
+
else
|
|
228
|
+
for (B = 0; B < ee; B++) {
|
|
229
|
+
for (j = 0; j < V; j++) {
|
|
230
|
+
U = u[j];
|
|
231
|
+
const { h: a, v: f } = U;
|
|
232
|
+
for (G = 0; G < f; G++)
|
|
233
|
+
for (X = 0; X < a; X++)
|
|
234
|
+
se(U, H, M, G, X);
|
|
235
|
+
}
|
|
236
|
+
if (M++, M === J)
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
if (d = 0, z = q[b] << 8 | q[b + 1], z < 65280)
|
|
240
|
+
throw new Error("marker was not found");
|
|
241
|
+
if (z >= 65488 && z <= 65495)
|
|
242
|
+
b += 2;
|
|
243
|
+
else
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
return b - r;
|
|
247
|
+
}
|
|
248
|
+
function ie(q, l) {
|
|
249
|
+
const o = [], { blocksPerLine: u, blocksPerColumn: T } = l, w = u << 3, C = new Int32Array(64), t = new Uint8Array(64);
|
|
250
|
+
function h(F, c, r) {
|
|
251
|
+
const b = l.quantizationTable;
|
|
252
|
+
let i, d, m, x, E, k, A, v, s;
|
|
253
|
+
const n = r;
|
|
254
|
+
let g;
|
|
255
|
+
for (g = 0; g < 64; g++)
|
|
256
|
+
n[g] = F[g] * b[g];
|
|
257
|
+
for (g = 0; g < 8; ++g) {
|
|
258
|
+
const e = 8 * g;
|
|
259
|
+
if (n[1 + e] === 0 && n[2 + e] === 0 && n[3 + e] === 0 && n[4 + e] === 0 && n[5 + e] === 0 && n[6 + e] === 0 && n[7 + e] === 0) {
|
|
260
|
+
s = R * n[0 + e] + 512 >> 10, n[0 + e] = s, n[1 + e] = s, n[2 + e] = s, n[3 + e] = s, n[4 + e] = s, n[5 + e] = s, n[6 + e] = s, n[7 + e] = s;
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
i = R * n[0 + e] + 128 >> 8, d = R * n[4 + e] + 128 >> 8, m = n[2 + e], x = n[6 + e], E = K * (n[1 + e] - n[7 + e]) + 128 >> 8, v = K * (n[1 + e] + n[7 + e]) + 128 >> 8, k = n[3 + e] << 4, A = n[5 + e] << 4, s = i - d + 1 >> 1, i = i + d + 1 >> 1, d = s, s = m * W + x * Q + 128 >> 8, m = m * Q - x * W + 128 >> 8, x = s, s = E - A + 1 >> 1, E = E + A + 1 >> 1, A = s, s = v + k + 1 >> 1, k = v - k + 1 >> 1, v = s, s = i - x + 1 >> 1, i = i + x + 1 >> 1, x = s, s = d - m + 1 >> 1, d = d + m + 1 >> 1, m = s, s = E * N + v * $ + 2048 >> 12, E = E * $ - v * N + 2048 >> 12, v = s, s = k * Z + A * Y + 2048 >> 12, k = k * Y - A * Z + 2048 >> 12, A = s, n[0 + e] = i + v, n[7 + e] = i - v, n[1 + e] = d + A, n[6 + e] = d - A, n[2 + e] = m + k, n[5 + e] = m - k, n[3 + e] = x + E, n[4 + e] = x - E;
|
|
264
|
+
}
|
|
265
|
+
for (g = 0; g < 8; ++g) {
|
|
266
|
+
const e = g;
|
|
267
|
+
if (n[1 * 8 + e] === 0 && n[2 * 8 + e] === 0 && n[3 * 8 + e] === 0 && n[4 * 8 + e] === 0 && n[5 * 8 + e] === 0 && n[6 * 8 + e] === 0 && n[7 * 8 + e] === 0) {
|
|
268
|
+
s = R * r[g + 0] + 8192 >> 14, n[0 * 8 + e] = s, n[1 * 8 + e] = s, n[2 * 8 + e] = s, n[3 * 8 + e] = s, n[4 * 8 + e] = s, n[5 * 8 + e] = s, n[6 * 8 + e] = s, n[7 * 8 + e] = s;
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
i = R * n[0 * 8 + e] + 2048 >> 12, d = R * n[4 * 8 + e] + 2048 >> 12, m = n[2 * 8 + e], x = n[6 * 8 + e], E = K * (n[1 * 8 + e] - n[7 * 8 + e]) + 2048 >> 12, v = K * (n[1 * 8 + e] + n[7 * 8 + e]) + 2048 >> 12, k = n[3 * 8 + e], A = n[5 * 8 + e], s = i - d + 1 >> 1, i = i + d + 1 >> 1, d = s, s = m * W + x * Q + 2048 >> 12, m = m * Q - x * W + 2048 >> 12, x = s, s = E - A + 1 >> 1, E = E + A + 1 >> 1, A = s, s = v + k + 1 >> 1, k = v - k + 1 >> 1, v = s, s = i - x + 1 >> 1, i = i + x + 1 >> 1, x = s, s = d - m + 1 >> 1, d = d + m + 1 >> 1, m = s, s = E * N + v * $ + 2048 >> 12, E = E * $ - v * N + 2048 >> 12, v = s, s = k * Z + A * Y + 2048 >> 12, k = k * Y - A * Z + 2048 >> 12, A = s, n[0 * 8 + e] = i + v, n[7 * 8 + e] = i - v, n[1 * 8 + e] = d + A, n[6 * 8 + e] = d - A, n[2 * 8 + e] = m + k, n[5 * 8 + e] = m - k, n[3 * 8 + e] = x + E, n[4 * 8 + e] = x - E;
|
|
272
|
+
}
|
|
273
|
+
for (g = 0; g < 64; ++g) {
|
|
274
|
+
const e = 128 + (n[g] + 8 >> 4);
|
|
275
|
+
e < 0 ? c[g] = 0 : e > 255 ? c[g] = 255 : c[g] = e;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
for (let F = 0; F < T; F++) {
|
|
279
|
+
const c = F << 3;
|
|
280
|
+
for (let r = 0; r < 8; r++)
|
|
281
|
+
o.push(new Uint8Array(w));
|
|
282
|
+
for (let r = 0; r < u; r++) {
|
|
283
|
+
h(l.blocks[F][r], t, C);
|
|
284
|
+
let b = 0;
|
|
285
|
+
const i = r << 3;
|
|
286
|
+
for (let d = 0; d < 8; d++) {
|
|
287
|
+
const m = o[c + d];
|
|
288
|
+
for (let x = 0; x < 8; x++)
|
|
289
|
+
m[i + x] = t[b++];
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return o;
|
|
294
|
+
}
|
|
295
|
+
class le {
|
|
296
|
+
constructor() {
|
|
297
|
+
this.jfif = null, this.adobe = null, this.quantizationTables = [], this.huffmanTablesAC = [], this.huffmanTablesDC = [], this.resetFrames();
|
|
298
|
+
}
|
|
299
|
+
resetFrames() {
|
|
300
|
+
this.frames = [];
|
|
301
|
+
}
|
|
302
|
+
parse(l) {
|
|
303
|
+
let o = 0;
|
|
304
|
+
function u() {
|
|
305
|
+
const t = l[o] << 8 | l[o + 1];
|
|
306
|
+
return o += 2, t;
|
|
307
|
+
}
|
|
308
|
+
function T() {
|
|
309
|
+
const t = u(), h = l.subarray(o, o + t - 2);
|
|
310
|
+
return o += h.length, h;
|
|
311
|
+
}
|
|
312
|
+
function w(t) {
|
|
313
|
+
let h = 0, F = 0, c, r;
|
|
314
|
+
for (r in t.components)
|
|
315
|
+
t.components.hasOwnProperty(r) && (c = t.components[r], h < c.h && (h = c.h), F < c.v && (F = c.v));
|
|
316
|
+
const b = Math.ceil(t.samplesPerLine / 8 / h), i = Math.ceil(t.scanLines / 8 / F);
|
|
317
|
+
for (r in t.components)
|
|
318
|
+
if (t.components.hasOwnProperty(r)) {
|
|
319
|
+
c = t.components[r];
|
|
320
|
+
const d = Math.ceil(Math.ceil(t.samplesPerLine / 8) * c.h / h), m = Math.ceil(Math.ceil(t.scanLines / 8) * c.v / F), x = b * c.h, E = i * c.v, k = [];
|
|
321
|
+
for (let A = 0; A < E; A++) {
|
|
322
|
+
const v = [];
|
|
323
|
+
for (let s = 0; s < x; s++)
|
|
324
|
+
v.push(new Int32Array(64));
|
|
325
|
+
k.push(v);
|
|
326
|
+
}
|
|
327
|
+
c.blocksPerLine = d, c.blocksPerColumn = m, c.blocks = k;
|
|
328
|
+
}
|
|
329
|
+
t.maxH = h, t.maxV = F, t.mcusPerLine = b, t.mcusPerColumn = i;
|
|
330
|
+
}
|
|
331
|
+
let C = u();
|
|
332
|
+
if (C !== 65496)
|
|
333
|
+
throw new Error("SOI not found");
|
|
334
|
+
for (C = u(); C !== 65497; ) {
|
|
335
|
+
switch (C) {
|
|
336
|
+
case 65280:
|
|
337
|
+
break;
|
|
338
|
+
case 65504:
|
|
339
|
+
// APP0 (Application Specific)
|
|
340
|
+
case 65505:
|
|
341
|
+
// APP1
|
|
342
|
+
case 65506:
|
|
343
|
+
// APP2
|
|
344
|
+
case 65507:
|
|
345
|
+
// APP3
|
|
346
|
+
case 65508:
|
|
347
|
+
// APP4
|
|
348
|
+
case 65509:
|
|
349
|
+
// APP5
|
|
350
|
+
case 65510:
|
|
351
|
+
// APP6
|
|
352
|
+
case 65511:
|
|
353
|
+
// APP7
|
|
354
|
+
case 65512:
|
|
355
|
+
// APP8
|
|
356
|
+
case 65513:
|
|
357
|
+
// APP9
|
|
358
|
+
case 65514:
|
|
359
|
+
// APP10
|
|
360
|
+
case 65515:
|
|
361
|
+
// APP11
|
|
362
|
+
case 65516:
|
|
363
|
+
// APP12
|
|
364
|
+
case 65517:
|
|
365
|
+
// APP13
|
|
366
|
+
case 65518:
|
|
367
|
+
// APP14
|
|
368
|
+
case 65519:
|
|
369
|
+
// APP15
|
|
370
|
+
case 65534: {
|
|
371
|
+
const t = T();
|
|
372
|
+
C === 65504 && t[0] === 74 && t[1] === 70 && t[2] === 73 && t[3] === 70 && t[4] === 0 && (this.jfif = {
|
|
373
|
+
version: { major: t[5], minor: t[6] },
|
|
374
|
+
densityUnits: t[7],
|
|
375
|
+
xDensity: t[8] << 8 | t[9],
|
|
376
|
+
yDensity: t[10] << 8 | t[11],
|
|
377
|
+
thumbWidth: t[12],
|
|
378
|
+
thumbHeight: t[13],
|
|
379
|
+
thumbData: t.subarray(14, 14 + 3 * t[12] * t[13])
|
|
380
|
+
}), C === 65518 && t[0] === 65 && t[1] === 100 && t[2] === 111 && t[3] === 98 && t[4] === 101 && t[5] === 0 && (this.adobe = {
|
|
381
|
+
version: t[6],
|
|
382
|
+
flags0: t[7] << 8 | t[8],
|
|
383
|
+
flags1: t[9] << 8 | t[10],
|
|
384
|
+
transformCode: t[11]
|
|
385
|
+
});
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
case 65499: {
|
|
389
|
+
const h = u() + o - 2;
|
|
390
|
+
for (; o < h; ) {
|
|
391
|
+
const F = l[o++], c = new Int32Array(64);
|
|
392
|
+
if (F >> 4 === 0)
|
|
393
|
+
for (let r = 0; r < 64; r++) {
|
|
394
|
+
const b = O[r];
|
|
395
|
+
c[b] = l[o++];
|
|
396
|
+
}
|
|
397
|
+
else if (F >> 4 === 1)
|
|
398
|
+
for (let r = 0; r < 64; r++) {
|
|
399
|
+
const b = O[r];
|
|
400
|
+
c[b] = u();
|
|
401
|
+
}
|
|
402
|
+
else
|
|
403
|
+
throw new Error("DQT: invalid table spec");
|
|
404
|
+
this.quantizationTables[F & 15] = c;
|
|
405
|
+
}
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
case 65472:
|
|
409
|
+
// SOF0 (Start of Frame, Baseline DCT)
|
|
410
|
+
case 65473:
|
|
411
|
+
// SOF1 (Start of Frame, Extended DCT)
|
|
412
|
+
case 65474: {
|
|
413
|
+
u();
|
|
414
|
+
const t = {
|
|
415
|
+
extended: C === 65473,
|
|
416
|
+
progressive: C === 65474,
|
|
417
|
+
precision: l[o++],
|
|
418
|
+
scanLines: u(),
|
|
419
|
+
samplesPerLine: u(),
|
|
420
|
+
components: {},
|
|
421
|
+
componentsOrder: []
|
|
422
|
+
}, h = l[o++];
|
|
423
|
+
let F;
|
|
424
|
+
for (let c = 0; c < h; c++) {
|
|
425
|
+
F = l[o];
|
|
426
|
+
const r = l[o + 1] >> 4, b = l[o + 1] & 15, i = l[o + 2];
|
|
427
|
+
t.componentsOrder.push(F), t.components[F] = {
|
|
428
|
+
h: r,
|
|
429
|
+
v: b,
|
|
430
|
+
quantizationIdx: i
|
|
431
|
+
}, o += 3;
|
|
432
|
+
}
|
|
433
|
+
w(t), this.frames.push(t);
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
case 65476: {
|
|
437
|
+
const t = u();
|
|
438
|
+
for (let h = 2; h < t; ) {
|
|
439
|
+
const F = l[o++], c = new Uint8Array(16);
|
|
440
|
+
let r = 0;
|
|
441
|
+
for (let i = 0; i < 16; i++, o++)
|
|
442
|
+
c[i] = l[o], r += c[i];
|
|
443
|
+
const b = new Uint8Array(r);
|
|
444
|
+
for (let i = 0; i < r; i++, o++)
|
|
445
|
+
b[i] = l[o];
|
|
446
|
+
h += 17 + r, F >> 4 === 0 ? this.huffmanTablesDC[F & 15] = ne(
|
|
447
|
+
c,
|
|
448
|
+
b
|
|
449
|
+
) : this.huffmanTablesAC[F & 15] = ne(
|
|
450
|
+
c,
|
|
451
|
+
b
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
case 65501:
|
|
457
|
+
u(), this.resetInterval = u();
|
|
458
|
+
break;
|
|
459
|
+
case 65498: {
|
|
460
|
+
u();
|
|
461
|
+
const t = l[o++], h = [], F = this.frames[0];
|
|
462
|
+
for (let d = 0; d < t; d++) {
|
|
463
|
+
const m = F.components[l[o++]], x = l[o++];
|
|
464
|
+
m.huffmanTableDC = this.huffmanTablesDC[x >> 4], m.huffmanTableAC = this.huffmanTablesAC[x & 15], h.push(m);
|
|
465
|
+
}
|
|
466
|
+
const c = l[o++], r = l[o++], b = l[o++], i = ce(
|
|
467
|
+
l,
|
|
468
|
+
o,
|
|
469
|
+
F,
|
|
470
|
+
h,
|
|
471
|
+
this.resetInterval,
|
|
472
|
+
c,
|
|
473
|
+
r,
|
|
474
|
+
b >> 4,
|
|
475
|
+
b & 15
|
|
476
|
+
);
|
|
477
|
+
o += i;
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
case 65535:
|
|
481
|
+
l[o] !== 255 && o--;
|
|
482
|
+
break;
|
|
483
|
+
default:
|
|
484
|
+
if (l[o - 3] === 255 && l[o - 2] >= 192 && l[o - 2] <= 254) {
|
|
485
|
+
o -= 3;
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
throw new Error(`unknown JPEG marker ${C.toString(16)}`);
|
|
489
|
+
}
|
|
490
|
+
C = u();
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
getResult() {
|
|
494
|
+
const { frames: l } = this;
|
|
495
|
+
if (this.frames.length === 0)
|
|
496
|
+
throw new Error("no frames were decoded");
|
|
497
|
+
this.frames.length > 1 && console.warn("more than one frame is not supported");
|
|
498
|
+
for (let c = 0; c < this.frames.length; c++) {
|
|
499
|
+
const r = this.frames[c].components;
|
|
500
|
+
for (const b of Object.keys(r))
|
|
501
|
+
r[b].quantizationTable = this.quantizationTables[r[b].quantizationIdx], delete r[b].quantizationIdx;
|
|
502
|
+
}
|
|
503
|
+
const o = l[0], { components: u, componentsOrder: T } = o, w = [], C = o.samplesPerLine, t = o.scanLines;
|
|
504
|
+
for (let c = 0; c < T.length; c++) {
|
|
505
|
+
const r = u[T[c]];
|
|
506
|
+
w.push({
|
|
507
|
+
lines: ie(o, r),
|
|
508
|
+
scaleX: r.h / o.maxH,
|
|
509
|
+
scaleY: r.v / o.maxV
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
const h = new Uint8Array(C * t * w.length);
|
|
513
|
+
let F = 0;
|
|
514
|
+
for (let c = 0; c < t; ++c)
|
|
515
|
+
for (let r = 0; r < C; ++r)
|
|
516
|
+
for (let b = 0; b < w.length; ++b) {
|
|
517
|
+
const i = w[b];
|
|
518
|
+
h[F] = i.lines[0 | c * i.scaleY][0 | r * i.scaleX], ++F;
|
|
519
|
+
}
|
|
520
|
+
return h;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
class fe extends re {
|
|
524
|
+
constructor(l) {
|
|
525
|
+
super(), this.reader = new le(), l.JPEGTables && this.reader.parse(l.JPEGTables);
|
|
526
|
+
}
|
|
527
|
+
decodeBlock(l) {
|
|
528
|
+
return this.reader.resetFrames(), this.reader.parse(new Uint8Array(l)), this.reader.getResult().buffer;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
export {
|
|
532
|
+
fe as default
|
|
533
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("./index-Ckhcz4QQ.cjs"),J=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),Y=4017,Z=799,$=3406,N=2276,Q=1567,W=3784,R=5793,K=2896;function ne(q,l){let o=0;const u=[];let D=16;for(;D>0&&!q[D-1];)--D;u.push({children:[],index:0});let w=u[0],C;for(let t=0;t<D;t++){for(let h=0;h<q[t];h++){for(w=u.pop(),w.children[w.index]=l[o];w.index>0;)w=u.pop();for(w.index++,u.push(w);u.length<=t;)u.push(C={children:[],index:0}),w.children[w.index]=C.children,w=C;o++}t+1<D&&(u.push(C={children:[],index:0}),w.children[w.index]=C.children,w=C)}return u[0].children}function ce(q,l,o,u,D,w,C,t,h){const{mcusPerLine:F,progressive:c}=o,r=l;let b=l,i=0,d=0;function x(){if(d>0)return d--,i>>d&1;if(i=q[b++],i===255){const a=q[b++];if(a)throw new Error(`unexpected marker: ${(i<<8|a).toString(16)}`)}return d=7,i>>>7}function m(a){let f=a,p;for(;(p=x())!==null;){if(f=f[p],typeof f=="number")return f;if(typeof f!="object")throw new Error("invalid huffman sequence")}return null}function E(a){let f=a,p=0;for(;f>0;){const y=x();if(y===null)return;p=p<<1|y,--f}return p}function k(a){const f=E(a);return f>=1<<a-1?f:f+(-1<<a)+1}function v(a,f){const p=m(a.huffmanTableDC),y=p===0?0:k(p);a.pred+=y,f[0]=a.pred;let P=1;for(;P<64;){const T=m(a.huffmanTableAC),L=T&15,S=T>>4;if(L===0){if(S<15)break;P+=16}else{P+=S;const I=J[P];f[I]=k(L),P++}}}function A(a,f){const p=m(a.huffmanTableDC),y=p===0?0:k(p)<<h;a.pred+=y,f[0]=a.pred}function s(a,f){f[0]|=x()<<h}let n=0;function g(a,f){if(n>0){n--;return}let p=w;const y=C;for(;p<=y;){const P=m(a.huffmanTableAC),T=P&15,L=P>>4;if(T===0){if(L<15){n=E(L)+(1<<L)-1;break}p+=16}else{p+=L;const S=J[p];f[S]=k(T)*(1<<h),p++}}}let e=0,_;function te(a,f){let p=w;const y=C;let P=0;for(;p<=y;){const T=J[p],L=f[T]<0?-1:1;switch(e){case 0:{const S=m(a.huffmanTableAC),I=S&15;if(P=S>>4,I===0)P<15?(n=E(P)+(1<<P),e=4):(P=16,e=1);else{if(I!==1)throw new Error("invalid ACn encoding");_=k(I),e=P?2:3}continue}case 1:case 2:f[T]?f[T]+=(x()<<h)*L:(P--,P===0&&(e=e===2?3:0));break;case 3:f[T]?f[T]+=(x()<<h)*L:(f[T]=_<<h,e=0);break;case 4:f[T]&&(f[T]+=(x()<<h)*L);break}p++}e===4&&(n--,n===0&&(e=0))}function se(a,f,p,y,P){const T=p/F|0,L=p%F,S=T*a.v+y,I=L*a.h+P;f(a,a.blocks[S][I])}function oe(a,f,p){const y=p/a.blocksPerLine|0,P=p%a.blocksPerLine;f(a,a.blocks[y][P])}const V=u.length;let U,j,G,X,M,H;c?w===0?H=t===0?A:s:H=t===0?g:te:H=v;let B=0,z,O;V===1?O=u[0].blocksPerLine*u[0].blocksPerColumn:O=F*o.mcusPerColumn;const ee=D||O;for(;B<O;){for(j=0;j<V;j++)u[j].pred=0;if(n=0,V===1)for(U=u[0],M=0;M<ee;M++)oe(U,H,B),B++;else for(M=0;M<ee;M++){for(j=0;j<V;j++){U=u[j];const{h:a,v:f}=U;for(G=0;G<f;G++)for(X=0;X<a;X++)se(U,H,B,G,X)}if(B++,B===O)break}if(d=0,z=q[b]<<8|q[b+1],z<65280)throw new Error("marker was not found");if(z>=65488&&z<=65495)b+=2;else break}return b-r}function ie(q,l){const o=[],{blocksPerLine:u,blocksPerColumn:D}=l,w=u<<3,C=new Int32Array(64),t=new Uint8Array(64);function h(F,c,r){const b=l.quantizationTable;let i,d,x,m,E,k,v,A,s;const n=r;let g;for(g=0;g<64;g++)n[g]=F[g]*b[g];for(g=0;g<8;++g){const e=8*g;if(n[1+e]===0&&n[2+e]===0&&n[3+e]===0&&n[4+e]===0&&n[5+e]===0&&n[6+e]===0&&n[7+e]===0){s=R*n[0+e]+512>>10,n[0+e]=s,n[1+e]=s,n[2+e]=s,n[3+e]=s,n[4+e]=s,n[5+e]=s,n[6+e]=s,n[7+e]=s;continue}i=R*n[0+e]+128>>8,d=R*n[4+e]+128>>8,x=n[2+e],m=n[6+e],E=K*(n[1+e]-n[7+e])+128>>8,A=K*(n[1+e]+n[7+e])+128>>8,k=n[3+e]<<4,v=n[5+e]<<4,s=i-d+1>>1,i=i+d+1>>1,d=s,s=x*W+m*Q+128>>8,x=x*Q-m*W+128>>8,m=s,s=E-v+1>>1,E=E+v+1>>1,v=s,s=A+k+1>>1,k=A-k+1>>1,A=s,s=i-m+1>>1,i=i+m+1>>1,m=s,s=d-x+1>>1,d=d+x+1>>1,x=s,s=E*N+A*$+2048>>12,E=E*$-A*N+2048>>12,A=s,s=k*Z+v*Y+2048>>12,k=k*Y-v*Z+2048>>12,v=s,n[0+e]=i+A,n[7+e]=i-A,n[1+e]=d+v,n[6+e]=d-v,n[2+e]=x+k,n[5+e]=x-k,n[3+e]=m+E,n[4+e]=m-E}for(g=0;g<8;++g){const e=g;if(n[1*8+e]===0&&n[2*8+e]===0&&n[3*8+e]===0&&n[4*8+e]===0&&n[5*8+e]===0&&n[6*8+e]===0&&n[7*8+e]===0){s=R*r[g+0]+8192>>14,n[0*8+e]=s,n[1*8+e]=s,n[2*8+e]=s,n[3*8+e]=s,n[4*8+e]=s,n[5*8+e]=s,n[6*8+e]=s,n[7*8+e]=s;continue}i=R*n[0*8+e]+2048>>12,d=R*n[4*8+e]+2048>>12,x=n[2*8+e],m=n[6*8+e],E=K*(n[1*8+e]-n[7*8+e])+2048>>12,A=K*(n[1*8+e]+n[7*8+e])+2048>>12,k=n[3*8+e],v=n[5*8+e],s=i-d+1>>1,i=i+d+1>>1,d=s,s=x*W+m*Q+2048>>12,x=x*Q-m*W+2048>>12,m=s,s=E-v+1>>1,E=E+v+1>>1,v=s,s=A+k+1>>1,k=A-k+1>>1,A=s,s=i-m+1>>1,i=i+m+1>>1,m=s,s=d-x+1>>1,d=d+x+1>>1,x=s,s=E*N+A*$+2048>>12,E=E*$-A*N+2048>>12,A=s,s=k*Z+v*Y+2048>>12,k=k*Y-v*Z+2048>>12,v=s,n[0*8+e]=i+A,n[7*8+e]=i-A,n[1*8+e]=d+v,n[6*8+e]=d-v,n[2*8+e]=x+k,n[5*8+e]=x-k,n[3*8+e]=m+E,n[4*8+e]=m-E}for(g=0;g<64;++g){const e=128+(n[g]+8>>4);e<0?c[g]=0:e>255?c[g]=255:c[g]=e}}for(let F=0;F<D;F++){const c=F<<3;for(let r=0;r<8;r++)o.push(new Uint8Array(w));for(let r=0;r<u;r++){h(l.blocks[F][r],t,C);let b=0;const i=r<<3;for(let d=0;d<8;d++){const x=o[c+d];for(let m=0;m<8;m++)x[i+m]=t[b++]}}}return o}class le{constructor(){this.jfif=null,this.adobe=null,this.quantizationTables=[],this.huffmanTablesAC=[],this.huffmanTablesDC=[],this.resetFrames()}resetFrames(){this.frames=[]}parse(l){let o=0;function u(){const t=l[o]<<8|l[o+1];return o+=2,t}function D(){const t=u(),h=l.subarray(o,o+t-2);return o+=h.length,h}function w(t){let h=0,F=0,c,r;for(r in t.components)t.components.hasOwnProperty(r)&&(c=t.components[r],h<c.h&&(h=c.h),F<c.v&&(F=c.v));const b=Math.ceil(t.samplesPerLine/8/h),i=Math.ceil(t.scanLines/8/F);for(r in t.components)if(t.components.hasOwnProperty(r)){c=t.components[r];const d=Math.ceil(Math.ceil(t.samplesPerLine/8)*c.h/h),x=Math.ceil(Math.ceil(t.scanLines/8)*c.v/F),m=b*c.h,E=i*c.v,k=[];for(let v=0;v<E;v++){const A=[];for(let s=0;s<m;s++)A.push(new Int32Array(64));k.push(A)}c.blocksPerLine=d,c.blocksPerColumn=x,c.blocks=k}t.maxH=h,t.maxV=F,t.mcusPerLine=b,t.mcusPerColumn=i}let C=u();if(C!==65496)throw new Error("SOI not found");for(C=u();C!==65497;){switch(C){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:{const t=D();C===65504&&t[0]===74&&t[1]===70&&t[2]===73&&t[3]===70&&t[4]===0&&(this.jfif={version:{major:t[5],minor:t[6]},densityUnits:t[7],xDensity:t[8]<<8|t[9],yDensity:t[10]<<8|t[11],thumbWidth:t[12],thumbHeight:t[13],thumbData:t.subarray(14,14+3*t[12]*t[13])}),C===65518&&t[0]===65&&t[1]===100&&t[2]===111&&t[3]===98&&t[4]===101&&t[5]===0&&(this.adobe={version:t[6],flags0:t[7]<<8|t[8],flags1:t[9]<<8|t[10],transformCode:t[11]});break}case 65499:{const h=u()+o-2;for(;o<h;){const F=l[o++],c=new Int32Array(64);if(F>>4===0)for(let r=0;r<64;r++){const b=J[r];c[b]=l[o++]}else if(F>>4===1)for(let r=0;r<64;r++){const b=J[r];c[b]=u()}else throw new Error("DQT: invalid table spec");this.quantizationTables[F&15]=c}break}case 65472:case 65473:case 65474:{u();const t={extended:C===65473,progressive:C===65474,precision:l[o++],scanLines:u(),samplesPerLine:u(),components:{},componentsOrder:[]},h=l[o++];let F;for(let c=0;c<h;c++){F=l[o];const r=l[o+1]>>4,b=l[o+1]&15,i=l[o+2];t.componentsOrder.push(F),t.components[F]={h:r,v:b,quantizationIdx:i},o+=3}w(t),this.frames.push(t);break}case 65476:{const t=u();for(let h=2;h<t;){const F=l[o++],c=new Uint8Array(16);let r=0;for(let i=0;i<16;i++,o++)c[i]=l[o],r+=c[i];const b=new Uint8Array(r);for(let i=0;i<r;i++,o++)b[i]=l[o];h+=17+r,F>>4===0?this.huffmanTablesDC[F&15]=ne(c,b):this.huffmanTablesAC[F&15]=ne(c,b)}break}case 65501:u(),this.resetInterval=u();break;case 65498:{u();const t=l[o++],h=[],F=this.frames[0];for(let d=0;d<t;d++){const x=F.components[l[o++]],m=l[o++];x.huffmanTableDC=this.huffmanTablesDC[m>>4],x.huffmanTableAC=this.huffmanTablesAC[m&15],h.push(x)}const c=l[o++],r=l[o++],b=l[o++],i=ce(l,o,F,h,this.resetInterval,c,r,b>>4,b&15);o+=i;break}case 65535:l[o]!==255&&o--;break;default:if(l[o-3]===255&&l[o-2]>=192&&l[o-2]<=254){o-=3;break}throw new Error(`unknown JPEG marker ${C.toString(16)}`)}C=u()}}getResult(){const{frames:l}=this;if(this.frames.length===0)throw new Error("no frames were decoded");this.frames.length>1&&console.warn("more than one frame is not supported");for(let c=0;c<this.frames.length;c++){const r=this.frames[c].components;for(const b of Object.keys(r))r[b].quantizationTable=this.quantizationTables[r[b].quantizationIdx],delete r[b].quantizationIdx}const o=l[0],{components:u,componentsOrder:D}=o,w=[],C=o.samplesPerLine,t=o.scanLines;for(let c=0;c<D.length;c++){const r=u[D[c]];w.push({lines:ie(o,r),scaleX:r.h/o.maxH,scaleY:r.v/o.maxV})}const h=new Uint8Array(C*t*w.length);let F=0;for(let c=0;c<t;++c)for(let r=0;r<C;++r)for(let b=0;b<w.length;++b){const i=w[b];h[F]=i.lines[0|c*i.scaleY][0|r*i.scaleX],++F}return h}}class ae extends re.BaseDecoder{constructor(l){super(),this.reader=new le,l.JPEGTables&&this.reader.parse(l.JPEGTables)}decodeBlock(l){return this.reader.resetFrames(),this.reader.parse(new Uint8Array(l)),this.reader.getResult().buffer}}exports.default=ae;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var a = Object.defineProperty;
|
|
2
|
+
var c = (r, e, t) => e in r ? a(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var n = (r, e, t) => c(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { JpxImage as d } from "https://cdn.jsdelivr.net/gh/mozilla/pdf.js@30bd5f0/src/core/jpx.js";
|
|
5
|
+
const o = class o {
|
|
6
|
+
constructor() {
|
|
7
|
+
n(this, "kind", "bytes_to_bytes");
|
|
8
|
+
}
|
|
9
|
+
static fromConfig() {
|
|
10
|
+
return new o();
|
|
11
|
+
}
|
|
12
|
+
encode(e) {
|
|
13
|
+
throw new Error("encode not implemented");
|
|
14
|
+
}
|
|
15
|
+
async decode(e) {
|
|
16
|
+
const t = new d();
|
|
17
|
+
return t.failOnCorruptedImage = !0, t.parse(e), t.tiles[0].items;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
n(o, "codecId", "jpeg2k");
|
|
21
|
+
let s = o;
|
|
22
|
+
export {
|
|
23
|
+
s as default
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var c=Object.defineProperty;var i=(r,e,t)=>e in r?c(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var o=(r,e,t)=>i(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("https://cdn.jsdelivr.net/gh/mozilla/pdf.js@30bd5f0/src/core/jpx.js"),n=class n{constructor(){o(this,"kind","bytes_to_bytes")}static fromConfig(){return new n}encode(e){throw new Error("encode not implemented")}async decode(e){const t=new d.JpxImage;return t.failOnCorruptedImage=!0,t.parse(e),t.tiles[0].items}};o(n,"codecId","jpeg2k");let s=n;exports.default=s;
|