@beeintel/batch-image 0.0.0-stage → 1.0.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/FONT-LICENSE.txt +93 -0
- package/README.md +181 -2
- package/dist/assets/11st-D7qGO5e4.webp +0 -0
- package/dist/assets/UPNG-CPfdwFSy.js +2298 -0
- package/dist/assets/adjust-card-B63b81iV.webp +0 -0
- package/dist/assets/adjust-final.worker-C2JbTvv5.js +6945 -0
- package/dist/assets/amazon-CjTtpZTq.webp +0 -0
- package/dist/assets/ascii_art-B4UGbtGs.webp +0 -0
- package/dist/assets/auction-j26eVUQO.webp +0 -0
- package/dist/assets/background-DGdZUdkL.webp +0 -0
- package/dist/assets/background-card-wK7DRpvM.png +0 -0
- package/dist/assets/body-CUFdRg8w.webp +0 -0
- package/dist/assets/bounded-cutout.worker-BZR6mbaI.js +9615 -0
- package/dist/assets/brand-mark-card-cFUeDeO2.webp +0 -0
- package/dist/assets/buyma-dAxYNjow.webp +0 -0
- package/dist/assets/codec.worker-7W6hmsm6.js +7349 -0
- package/dist/assets/contour_lines-C_CqrgV1.webp +0 -0
- package/dist/assets/creema-B1tWyCPx.webp +0 -0
- package/dist/assets/crop-final.worker-Owin7TvX.js +7035 -0
- package/dist/assets/cutout-CzMvV5An.webp +0 -0
- package/dist/assets/cutout-card-CN4gNFBz.png +0 -0
- package/dist/assets/cutout.worker-DyH6Prbn.js +3894 -0
- package/dist/assets/depop-CkVC5Fn1.webp +0 -0
- package/dist/assets/dewrinkle-kFzP6LqD.webp +0 -0
- package/dist/assets/dither-CcxmO2e6.webp +0 -0
- package/dist/assets/douyin-CP_HwBDF.webp +0 -0
- package/dist/assets/download.worker-DnGSB6P_.js +17779 -0
- package/dist/assets/duotone-Cdg_3fQf.webp +0 -0
- package/dist/assets/ebay-CxLfrRAf.webp +0 -0
- package/dist/assets/edit-Cv-txfZm.webp +0 -0
- package/dist/assets/effect.worker-qu1eCcII.js +9227 -0
- package/dist/assets/engraving-BENh1O2O.webp +0 -0
- package/dist/assets/etsy-CSvz9GpY.webp +0 -0
- package/dist/assets/expand-C60VE9nK.webp +0 -0
- package/dist/assets/facebook-Ca2nJJiQ.webp +0 -0
- package/dist/assets/film_stock-Bqauwcq4.webp +0 -0
- package/dist/assets/final.worker-BnzJ3N5C.js +7035 -0
- package/dist/assets/final.worker-Csc1zoYS.js +7054 -0
- package/dist/assets/final.worker-DzBFT9xk.js +6922 -0
- package/dist/assets/final.worker-XpgKnlaz.js +7217 -0
- package/dist/assets/flatlay-CPiVmlAa.webp +0 -0
- package/dist/assets/flatlay-fold-B-CRYy87.webp +0 -0
- package/dist/assets/flatlay-open-Dzas8okC.webp +0 -0
- package/dist/assets/g-market-DXuYK_JH.webp +0 -0
- package/dist/assets/ghost-BCEAx_Zx.webp +0 -0
- package/dist/assets/ghost-front-WFgA4sUo.webp +0 -0
- package/dist/assets/ghost-three-quarter-Rt8cXj34.webp +0 -0
- package/dist/assets/gif-CObOIITx.js +303 -0
- package/dist/assets/glass_tiles-3IXP-Hmg.webp +0 -0
- package/dist/assets/glitch_art-D1i3qben.webp +0 -0
- package/dist/assets/glitch_blur-C4q_9zyq.webp +0 -0
- package/dist/assets/glow-Bv9EHBU5.webp +0 -0
- package/dist/assets/gradient_map-BR-UVYMP.webp +0 -0
- package/dist/assets/halftone-CWdKu2_6.webp +0 -0
- package/dist/assets/holo_sticker-BQDikLg2.webp +0 -0
- package/dist/assets/idus-7diqRNPs.webp +0 -0
- package/dist/assets/imagetracer.worker-CgunQTPG.js +7096 -0
- package/dist/assets/instagram-Bf0IVidT.webp +0 -0
- package/dist/assets/kakao-talk-Df79L_Mv.webp +0 -0
- package/dist/assets/kaleidoscope-BxqMZuWo.webp +0 -0
- package/dist/assets/karrot-BXFPhDwt.webp +0 -0
- package/dist/assets/kaufland-BDDy6e0C.webp +0 -0
- package/dist/assets/lazada-ConR4e1O.webp +0 -0
- package/dist/assets/lens_flare-DgyiAv_j.webp +0 -0
- package/dist/assets/light_leak-kUdpoFuC.webp +0 -0
- package/dist/assets/line-Dr1j___B.webp +0 -0
- package/dist/assets/linkedin-4s_9Wh03.webp +0 -0
- package/dist/assets/lo_fi-DSdl3yY_.webp +0 -0
- package/dist/assets/logo-preparation.worker-D9oa7SME.js +420 -0
- package/dist/assets/mercado-libre-C8CskEiS.webp +0 -0
- package/dist/assets/mercari-jp-DHj7nz4O.webp +0 -0
- package/dist/assets/metadata.worker-B_9_BgN1.js +6456 -0
- package/dist/assets/mirror_collage-JtSKCeSh.webp +0 -0
- package/dist/assets/model-BbeF-fsf.webp +0 -0
- package/dist/assets/model-BjWhieit.webp +0 -0
- package/dist/assets/momo-BWXO_8Df.webp +0 -0
- package/dist/assets/motion_blur-B8YUHeSg.webp +0 -0
- package/dist/assets/naver-xQKL8lWg.webp +0 -0
- package/dist/assets/nuvemshop-DPt6rnA-.webp +0 -0
- package/dist/assets/olx-B87gp-Il.webp +0 -0
- package/dist/assets/orient-card-Da0ii6mX.webp +0 -0
- package/dist/assets/orient-final.worker-CdF5Y5zD.js +6909 -0
- package/dist/assets/orientation-preview.worker-B7uFzz3J.js +6865 -0
- package/dist/assets/ort.bundle.min-CreFV8V1.js +9311 -0
- package/dist/assets/ort.webgpu.bundle.min-CAudaHZO.js +9311 -0
- package/dist/assets/otto-market-DWZyNKJn.webp +0 -0
- package/dist/assets/paper_texture-CXphyIrs.webp +0 -0
- package/dist/assets/pinterest-ByZqih2J.webp +0 -0
- package/dist/assets/polish-DFy6LNG7.webp +0 -0
- package/dist/assets/poshmark-DnZi2vA1.webp +0 -0
- package/dist/assets/posterize-SpLVGq1s.webp +0 -0
- package/dist/assets/preview.worker-DcrCKKWl.js +380 -0
- package/dist/assets/qoo10-C1pq81Jx.webp +0 -0
- package/dist/assets/rakuten-ulYog1hL.webp +0 -0
- package/dist/assets/recolor-mBX7vdFT.webp +0 -0
- package/dist/assets/resize-DVEAl0Um.webp +0 -0
- package/dist/assets/runtime-0663b902fb3937883a34.wasm +0 -0
- package/dist/assets/runtime-355a5c80c7bfdf8737de.mjs +2817 -0
- package/dist/assets/runtime-49871f5a4409519797e1.wasm +0 -0
- package/dist/assets/runtime-74cf72f9a2b7befc115a.mjs +2817 -0
- package/dist/assets/shadow-card-DTZEH60r.png +0 -0
- package/dist/assets/shopee-Bxfei6sj.webp +0 -0
- package/dist/assets/shopify-wVaBafcF.webp +0 -0
- package/dist/assets/shopline-DMoaJ7Bh.webp +0 -0
- package/dist/assets/sparkle-CD5GSGip.webp +0 -0
- package/dist/assets/ssg-DQoFx5u5.webp +0 -0
- package/dist/assets/staging-CIc8pQJ6.webp +0 -0
- package/dist/assets/standard-cutout.worker-BYLzdpR-.js +1261 -0
- package/dist/assets/text-DQW2mBGp.webp +0 -0
- package/dist/assets/textured_glass-D2coxp7n.webp +0 -0
- package/dist/assets/tga-VGxWDes0.js +752 -0
- package/dist/assets/tilt_shift-BKs46yeX.webp +0 -0
- package/dist/assets/transformers.web-DB57cIO5.js +28891 -0
- package/dist/assets/tritone-CcR4qizk.webp +0 -0
- package/dist/assets/upscale-BrLadyUk.webp +0 -0
- package/dist/assets/upscale-creative-DnZnQufJ.webp +0 -0
- package/dist/assets/upscale-crisp-Ckdmbsnn.webp +0 -0
- package/dist/assets/vinted-1QDsxvC6.webp +0 -0
- package/dist/assets/watercolor-CV67zYNE.webp +0 -0
- package/dist/assets/watermark-CpPrxaT5.webp +0 -0
- package/dist/assets/wave_distortion-CV5jVfK4.webp +0 -0
- package/dist/assets/whatsapp-CWJxqzR6.webp +0 -0
- package/dist/assets/worker-DfrCFP3O.js +55 -0
- package/dist/assets/xerox_noise-CbbHY1S1.webp +0 -0
- package/dist/assets/youtube-DS12d5mi.webp +0 -0
- package/dist/assets/zalando-CenfWOwz.webp +0 -0
- package/dist/browser-adapter.d.ts +4 -0
- package/dist/browser-cutout-capability.d.ts +4 -0
- package/dist/browser-cutout-resources.d.ts +3 -0
- package/dist/browser-local-capabilities.d.ts +5 -0
- package/dist/capabilities.d.ts +18 -0
- package/dist/chunks/AdjustToolPanel-B6dtlFlj.js +195 -0
- package/dist/chunks/BackgroundToolPanel-C3Rr9d4S.js +41 -0
- package/dist/chunks/BatchMaterials-DDoJTaS5.js +806 -0
- package/dist/chunks/BatchModeChoices-DeBARgvY.js +111 -0
- package/dist/chunks/BatchOutputColorPicker-D7WIDS4_.js +75 -0
- package/dist/chunks/BatchReferenceFields-Cr5WgFRJ.js +316 -0
- package/dist/chunks/BeautifyToolPanel-DDZXDQKM.js +215 -0
- package/dist/chunks/BrandMarkToolPanel-vKobk_R3.js +1179 -0
- package/dist/chunks/ContentTrimControl-BKCJEst5.js +297 -0
- package/dist/chunks/CropToolPanel-C_sW5tWL.js +218 -0
- package/dist/chunks/CutoutToolPanel-B7ObmiWd.js +73 -0
- package/dist/chunks/DisclosureToolPanel-F3ccFJIF.js +76 -0
- package/dist/chunks/ExpandToolPanel-BKjj5UJA.js +67 -0
- package/dist/chunks/ImageEffectsToolPanel-CsDIBpT6.js +966 -0
- package/dist/chunks/IpAuditToolPanel-CduDfFh-.js +96 -0
- package/dist/chunks/ListingToolPanel-8pJ2_zvI.js +783 -0
- package/dist/chunks/MaterialSelectionPlate-CW7HaS6v.js +30 -0
- package/dist/chunks/MetadataToolPanel-C8XJOamN.js +104 -0
- package/dist/chunks/OrientToolPanel-C1AzQchm.js +161 -0
- package/dist/chunks/PluginActionFooter.vue_vue_type_script_setup_true_lang-BGe419qz.js +102 -0
- package/dist/chunks/ResizeToolPanel-DWikcj2G.js +1178 -0
- package/dist/chunks/RetouchToolPanel-B4eQKk2W.js +350 -0
- package/dist/chunks/ShadowToolPanel-Bbj76hQd.js +254 -0
- package/dist/chunks/SvgExportToolPanel-BRxpzd7q.js +219 -0
- package/dist/chunks/TranslationToolPanel-Bxv8U2WY.js +125 -0
- package/dist/chunks/UpscaleToolPanel-BRIgpszs.js +127 -0
- package/dist/chunks/engine-D-T-1RSx.js +69 -0
- package/dist/chunks/entry-CboOSe2r.js +42945 -0
- package/dist/chunks/gpu-CScw5MNG.js +231 -0
- package/dist/chunks/hosted-resources-COzZ7nZY.js +8196 -0
- package/dist/chunks/loader-circle-CylCgDqP.js +16 -0
- package/dist/chunks/motionFeatures-D67ghPG1.js +4405 -0
- package/dist/chunks/search-BwsDnulU.js +18 -0
- package/dist/chunks/standard-cutout-vPpP6xBc.js +45 -0
- package/dist/chunks/static-logo-2F9ORZWc.js +34 -0
- package/dist/config.d.ts +66 -0
- package/dist/contracts.d.ts +272 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +13 -0
- package/dist/node/catalog.mjs +45 -0
- package/dist/node/cli.mjs +11 -0
- package/dist/node/index.d.mts +20 -0
- package/dist/node/index.mjs +2 -0
- package/dist/node/prepare.mjs +114 -0
- package/dist/node/vite.mjs +46 -0
- package/dist/processing.d.ts +1 -0
- package/dist/processing.js +12105 -0
- package/dist/remote-contracts.d.ts +114 -0
- package/dist/resource-contracts.d.ts +40 -0
- package/dist/resources/cutout/9ae2e5375a34fa413530954dc20d085d175faffc86108c13619220d0557f80bf.json +1 -0
- package/dist/resources/cutout/f119dabecc64bc436d3d08425dde96ec2598fd40541eba97d8d53a4e8bbdcaea.json +1 -0
- package/dist/resources/cutout/resources.json +195 -0
- package/dist/resources/cutout/sources.json +294 -0
- package/dist/resources.json +1191 -0
- package/dist/service-contracts.d.ts +43 -0
- package/dist/slots.d.ts +21 -0
- package/dist/style.css +1 -0
- package/dist/types/batch/api.d.ts +89 -0
- package/dist/types/batch/cutout-output.d.ts +2 -0
- package/dist/types/batch/features/background/engine.d.mts +12 -0
- package/dist/types/batch/features/basic-edit/contracts.d.ts +87 -0
- package/dist/types/batch/features/basic-edit/engine.d.mts +96 -0
- package/dist/types/batch/features/brand-mark/contracts.d.ts +84 -0
- package/dist/types/batch/features/brand-mark/engine.d.mts +68 -0
- package/dist/types/batch/features/export-compression/contracts.d.ts +44 -0
- package/dist/types/batch/features/export-compression/gifenc.d.ts +33 -0
- package/dist/types/batch/features/export-compression/plan.d.ts +45 -0
- package/dist/types/batch/features/export-compression/presentation.d.ts +70 -0
- package/dist/types/batch/features/export-compression/upng.d.ts +6 -0
- package/dist/types/batch/features/final-image/resize.d.mts +15 -0
- package/dist/types/batch/features/image-effects/contracts.d.ts +58 -0
- package/dist/types/batch/features/image-effects/gpu-pixel-runtime.d.ts +15 -0
- package/dist/types/batch/features/image-effects/photo-audit.d.ts +21 -0
- package/dist/types/batch/features/image-effects/photo-v7-cpu.d.ts +9 -0
- package/dist/types/batch/features/image-effects/profiles-v4.d.ts +157 -0
- package/dist/types/batch/features/image-effects/profiles-v5.d.ts +20 -0
- package/dist/types/batch/features/image-effects/profiles-v6.d.ts +14 -0
- package/dist/types/batch/features/image-effects/profiles-v7.d.ts +53 -0
- package/dist/types/batch/features/image-effects/profiles-v8.d.ts +113 -0
- package/dist/types/batch/features/image-effects/profiles-v9.d.ts +20 -0
- package/dist/types/batch/features/image-translation/params.d.ts +257 -0
- package/dist/types/batch/features/listing-remake/transport.d.ts +21 -0
- package/dist/types/batch/features/metadata/bytes.d.mts +13 -0
- package/dist/types/batch/features/metadata/containers.d.mts +20 -0
- package/dist/types/batch/features/metadata/declaration.d.mts +5 -0
- package/dist/types/batch/features/metadata/engine.d.mts +9 -0
- package/dist/types/batch/features/metadata/exchange.d.mts +48 -0
- package/dist/types/batch/features/shadow/contracts.d.ts +43 -0
- package/dist/types/batch/features/shadow/engine.d.mts +33 -0
- package/dist/types/batch/features/svg-export/download-contract.d.ts +33 -0
- package/dist/types/batch/features/svg-export/download-prepare.d.ts +2 -0
- package/dist/types/batch/features/svg-export/download.d.ts +7 -0
- package/dist/types/batch/features/svg-export/imagetracer.d.ts +6 -0
- package/dist/types/batch/features/svg-export/optimizer.d.ts +2 -0
- package/dist/types/batch/ids.d.ts +1 -0
- package/dist/types/batch/model.d.ts +317 -0
- package/dist/types/batch/public/config.d.ts +66 -0
- package/dist/types/batch/public/contracts.d.ts +272 -0
- package/dist/types/batch/public/remote-contracts.d.ts +114 -0
- package/dist/types/batch/public/resource-contracts.d.ts +40 -0
- package/dist/types/batch/public/service-contracts.d.ts +43 -0
- package/dist/types/batch/queue.d.ts +34 -0
- package/dist/types/batch/receipts.d.ts +85 -0
- package/dist/types/batch/retention.d.ts +13 -0
- package/dist/types/onnxruntime-web.d.ts +5 -0
- package/dist/types/plugins/cutout/core/hosted-resources.d.ts +11 -0
- package/dist/types/processing.d.ts +18 -0
- package/dist/types/shared/svg-security.d.mts +4 -0
- package/dist/types/workspace-worker.d.ts +2 -0
- package/package.json +91 -3
|
@@ -0,0 +1,752 @@
|
|
|
1
|
+
import { M as le, a as be } from "./codec.worker-7W6hmsm6.js";
|
|
2
|
+
var q = {}, L = {}, R = {}, x;
|
|
3
|
+
function he() {
|
|
4
|
+
if (x) return R;
|
|
5
|
+
x = 1, Object.defineProperty(R, "__esModule", { value: !0 }), R.handleWarning = R.EncodeWarning = R.EncodeError = void 0;
|
|
6
|
+
class i extends Error {
|
|
7
|
+
constructor(f, v) {
|
|
8
|
+
super(f), this.offset = v;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
R.EncodeError = i;
|
|
12
|
+
class w extends Error {
|
|
13
|
+
constructor(f, v) {
|
|
14
|
+
super(f), this.offset = v;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
R.EncodeWarning = w;
|
|
18
|
+
function h(u, f) {
|
|
19
|
+
if (u.options.strictMode)
|
|
20
|
+
throw f;
|
|
21
|
+
u.warnings.push(f);
|
|
22
|
+
}
|
|
23
|
+
return R.handleWarning = h, R;
|
|
24
|
+
}
|
|
25
|
+
var ee;
|
|
26
|
+
function Ee() {
|
|
27
|
+
if (ee) return L;
|
|
28
|
+
ee = 1, Object.defineProperty(L, "__esModule", { value: !0 }), L.analyze = void 0;
|
|
29
|
+
const i = he();
|
|
30
|
+
function w(o, l = {}) {
|
|
31
|
+
const _ = [], b = [], y = {
|
|
32
|
+
options: l,
|
|
33
|
+
warnings: _
|
|
34
|
+
};
|
|
35
|
+
if (o.width > 65535)
|
|
36
|
+
throw new i.EncodeError(`Image width is out of range (${o.width} > 65535)`, -1);
|
|
37
|
+
if (o.height > 65535)
|
|
38
|
+
throw new i.EncodeError(`Image height is out of range (${o.height} > 65535)`, -1);
|
|
39
|
+
if (o.data.length !== o.width * o.height * 4)
|
|
40
|
+
throw new i.EncodeError(`Provided image data length (${o.data.length}) is not expected length (${o.width * o.height * 4})`, Math.min(o.data.length, o.width * o.height * 4) - 1);
|
|
41
|
+
if (l.imageId && l.imageId.length > 255)
|
|
42
|
+
throw new i.EncodeError(`Image ID length is out of range (${l.imageId.length} > 255)`, -1);
|
|
43
|
+
if (l.origin && (l.origin.x || 0) > 65535)
|
|
44
|
+
throw new i.EncodeError(`X origin is out of range (${l.origin.x} > 65535)`, -1);
|
|
45
|
+
if (l.origin && (l.origin.y || 0) > 65535)
|
|
46
|
+
throw new i.EncodeError(`Y origin is out of range (${l.origin.y} > 65535)`, -1);
|
|
47
|
+
if (l.screenOrigin === 1 && (0, i.handleWarning)(y, new i.EncodeWarning("This image is encoded using a bottom right screen origin, many image editors won't read this correctly", 17)), l.screenOrigin === 3 && (0, i.handleWarning)(y, new i.EncodeWarning("This image is encoded using a top right screen origin, many image editors won't read this correctly", 17)), l.bitDepth !== void 0 && l.imageType === void 0 || l.bitDepth === void 0 && l.imageType !== void 0 && l.imageType >= 0)
|
|
48
|
+
throw new i.EncodeError("Bit depth and image type options must be used together", -1);
|
|
49
|
+
const U = l.imageType;
|
|
50
|
+
let T, A;
|
|
51
|
+
U !== void 0 && (U === -2 || U === -1 ? A = U : T = U);
|
|
52
|
+
let n = l.bitDepth, t;
|
|
53
|
+
if (n === 24 && h(o) && (0, i.handleWarning)({ options: l, warnings: _ }, new i.EncodeWarning("Cannot encode 24 bit image without data loss as it contains transparent colors", 0)), T === 9 || T === 1) {
|
|
54
|
+
const c = u(o, A);
|
|
55
|
+
if (!c.colorMap)
|
|
56
|
+
throw new i.EncodeError("Image has too many colors to encode using a color map", -1);
|
|
57
|
+
t = c.colorMap;
|
|
58
|
+
}
|
|
59
|
+
if (!n || A !== void 0) {
|
|
60
|
+
const c = u(o, A);
|
|
61
|
+
if (n && n < c.bitDepth)
|
|
62
|
+
throw new i.EncodeError("Image cannot be encoded using specified bit depth", -1);
|
|
63
|
+
n = c.bitDepth, T = c.imageType, t = c.colorMap;
|
|
64
|
+
}
|
|
65
|
+
if (!T)
|
|
66
|
+
throw new Error("No ImageType set");
|
|
67
|
+
return {
|
|
68
|
+
bitDepth: n,
|
|
69
|
+
imageType: T,
|
|
70
|
+
colorMap: t,
|
|
71
|
+
imageId: l.imageId || "",
|
|
72
|
+
options: l,
|
|
73
|
+
warnings: _,
|
|
74
|
+
info: b,
|
|
75
|
+
image: o
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
L.analyze = w;
|
|
79
|
+
function h(o) {
|
|
80
|
+
const _ = o.width * o.height * 4;
|
|
81
|
+
let b = !1;
|
|
82
|
+
for (let y = 0; y < _; y += 4)
|
|
83
|
+
b || (b = o.data[y + 3] < 255);
|
|
84
|
+
return b;
|
|
85
|
+
}
|
|
86
|
+
function u(o, l) {
|
|
87
|
+
const b = o.width * o.height * 4;
|
|
88
|
+
let y = !1, U = !1, T = !1, A = !1;
|
|
89
|
+
const n = /* @__PURE__ */ new Set();
|
|
90
|
+
for (let t = 0; t < b; t += 4)
|
|
91
|
+
y || (y = o.data[t + 3] > 0 && o.data[t + 3] < 255), U || (U = o.data[t + 3] < 255), T || T || (T = !v(o.data[t]) || !v(o.data[t + 1]) || !v(o.data[t + 2]) || !v(o.data[t + 3])), A || (A = o.data[t] !== o.data[t + 1] || o.data[t] !== o.data[t + 2]), n.size < 256 && n.add((o.data[t] << 24) + (o.data[t + 1] << 16) + (o.data[t + 2] << 8) + o.data[t + 3]);
|
|
92
|
+
if (n.size < 255) {
|
|
93
|
+
const t = /* @__PURE__ */ new Map();
|
|
94
|
+
let c = 0;
|
|
95
|
+
for (const B of n)
|
|
96
|
+
t.set(B, c++);
|
|
97
|
+
let E;
|
|
98
|
+
return T ? U ? E = { colorToIndexMap: t, bitDepth: 32 } : E = { colorToIndexMap: t, bitDepth: 24 } : U ? E = { colorToIndexMap: t, bitDepth: 32 } : E = { colorToIndexMap: t, bitDepth: 15 }, {
|
|
99
|
+
imageType: f(9, l),
|
|
100
|
+
bitDepth: 8,
|
|
101
|
+
colorMap: E
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return A ? T ? U ? { imageType: f(10, l), bitDepth: 32 } : { imageType: f(10, l), bitDepth: 24 } : U ? y ? { imageType: f(10, l), bitDepth: 32 } : { imageType: f(10, l), bitDepth: 16 } : { imageType: f(10, l), bitDepth: 15 } : U ? { imageType: f(11, l), bitDepth: 16 } : { imageType: f(11, l), bitDepth: 8 };
|
|
105
|
+
}
|
|
106
|
+
function f(o, l) {
|
|
107
|
+
if (l === void 0)
|
|
108
|
+
return o;
|
|
109
|
+
switch (o) {
|
|
110
|
+
case 1:
|
|
111
|
+
case 9:
|
|
112
|
+
return l === -2 ? 9 : 1;
|
|
113
|
+
case 2:
|
|
114
|
+
case 10:
|
|
115
|
+
return l === -2 ? 10 : 2;
|
|
116
|
+
case 3:
|
|
117
|
+
case 11:
|
|
118
|
+
return l === -2 ? 11 : 3;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function v(o) {
|
|
122
|
+
return (o >> 5 & 7) === (o & 7);
|
|
123
|
+
}
|
|
124
|
+
return L;
|
|
125
|
+
}
|
|
126
|
+
var G = {}, re;
|
|
127
|
+
function Te() {
|
|
128
|
+
if (re) return G;
|
|
129
|
+
re = 1, Object.defineProperty(G, "__esModule", { value: !0 }), G.ByteStream = void 0;
|
|
130
|
+
class i {
|
|
131
|
+
constructor(h, u) {
|
|
132
|
+
this._le = u, this.offset = 0, this.array = new Uint8Array(h), this.view = new DataView(this.array.buffer, this.array.byteOffset, this.array.byteLength);
|
|
133
|
+
}
|
|
134
|
+
writeUint8(h) {
|
|
135
|
+
this.view.setUint8(this.offset, h), this.offset += 1;
|
|
136
|
+
}
|
|
137
|
+
writeUint16(h) {
|
|
138
|
+
this.view.setUint16(this.offset, h, this._le), this.offset += 2;
|
|
139
|
+
}
|
|
140
|
+
assertAtEnd() {
|
|
141
|
+
if (this.offset !== this.array.length)
|
|
142
|
+
throw new Error("Writing finished before expected length of stream");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return G.ByteStream = i, G;
|
|
146
|
+
}
|
|
147
|
+
var F = {}, ne;
|
|
148
|
+
function ve() {
|
|
149
|
+
if (ne) return F;
|
|
150
|
+
ne = 1, Object.defineProperty(F, "__esModule", { value: !0 }), F.encodeRunLengthEncoding = void 0;
|
|
151
|
+
const i = he();
|
|
152
|
+
function w(h, u) {
|
|
153
|
+
const f = Math.ceil(h.bitDepth / 8), v = f + 1, o = new Uint8Array(h.image.width * h.image.height * v);
|
|
154
|
+
let l = 0, _ = 0, b = 1, y = 0, U = !1, T = 0, A = 0, n = !1;
|
|
155
|
+
for (let t = f; t < u.length; t += f) {
|
|
156
|
+
let c = !1;
|
|
157
|
+
for (y = 0; y < f; y++)
|
|
158
|
+
c || (c = u[_ + y] !== u[t + y]);
|
|
159
|
+
if (c) {
|
|
160
|
+
for (; b > 0; ) {
|
|
161
|
+
for (U = b === 1, n && U ? (T = o[A] & 127, T < 127 ? o[A] = T + 1 : (o[l] = Math.min(b, 128) - 1, A = l, l++)) : (o[l] = Math.min(b, 128) - 1 | (U ? 0 : 128), A = l, l++), y = 0; y < f; y++)
|
|
162
|
+
o[l + y] = u[_ + y];
|
|
163
|
+
l += f, n = U, b -= 128;
|
|
164
|
+
}
|
|
165
|
+
_ = t, b = 1;
|
|
166
|
+
} else
|
|
167
|
+
b++;
|
|
168
|
+
}
|
|
169
|
+
for (; b > 0; ) {
|
|
170
|
+
for (U = b === 1, n && U ? (T = o[A] & 127, T < 127 ? o[A] = T + 1 : (o[l] = Math.min(b, 128) - 1, A = l, l++)) : (o[l] = Math.min(b, 128) - 1 | (U ? 0 : 128), A = l, l++), y = 0; y < f; y++)
|
|
171
|
+
o[l + y] = u[_ + y];
|
|
172
|
+
l += f, b -= 128;
|
|
173
|
+
}
|
|
174
|
+
return l - 1 > u.length && (0, i.handleWarning)(h, new i.EncodeWarning("RLE encoded was used but it is larger than unencoded would be", -1)), o.slice(0, l);
|
|
175
|
+
}
|
|
176
|
+
return F.encodeRunLengthEncoding = w, F;
|
|
177
|
+
}
|
|
178
|
+
var te;
|
|
179
|
+
function Ae() {
|
|
180
|
+
if (te) return q;
|
|
181
|
+
te = 1, Object.defineProperty(q, "__esModule", { value: !0 }), q.encodeTga = void 0;
|
|
182
|
+
const i = Ee(), w = Te(), h = ve();
|
|
183
|
+
async function u(n, t = {}) {
|
|
184
|
+
const c = (0, i.analyze)(n, t), E = [];
|
|
185
|
+
E.push(f(c)), c.imageId.length > 0 && E.push(v(c)), c.colorMap && E.push(o(c)), E.push(l(c));
|
|
186
|
+
const B = E.reduce((W, e) => W + e.length, 0), P = new Uint8Array(B);
|
|
187
|
+
let M = 0;
|
|
188
|
+
for (const W of E)
|
|
189
|
+
P.set(W, M), M += W.length;
|
|
190
|
+
return {
|
|
191
|
+
data: P,
|
|
192
|
+
warnings: c.warnings,
|
|
193
|
+
info: c.info
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
q.encodeTga = u;
|
|
197
|
+
function f(n) {
|
|
198
|
+
const t = new w.ByteStream(18, !0);
|
|
199
|
+
t.writeUint8(n.imageId.length), t.writeUint8(n.colorMap ? 1 : 0), t.writeUint8(n.imageType), t.writeUint16(0), t.writeUint16(n.colorMap?.colorToIndexMap.size ?? 0), t.writeUint8(n.colorMap?.bitDepth ?? 0), t.writeUint16(n.options.origin?.x || 0), t.writeUint16(n.options.origin?.y || 0), t.writeUint16(n.image.width), t.writeUint16(n.image.height), t.writeUint8(n.bitDepth);
|
|
200
|
+
let c = 0;
|
|
201
|
+
n.bitDepth === 32 && (c = 8);
|
|
202
|
+
const E = c & 15 | (n.options.screenOrigin ?? 0) << 4 & 48;
|
|
203
|
+
return t.writeUint8(E), t.assertAtEnd(), t.array;
|
|
204
|
+
}
|
|
205
|
+
function v(n) {
|
|
206
|
+
const t = new w.ByteStream(n.imageId.length, !0);
|
|
207
|
+
for (let c = 0; c < n.imageId.length; c++)
|
|
208
|
+
t.writeUint8(n.imageId.charCodeAt(c));
|
|
209
|
+
return t.assertAtEnd(), t.array;
|
|
210
|
+
}
|
|
211
|
+
function o(n) {
|
|
212
|
+
const t = n.colorMap;
|
|
213
|
+
if (!t)
|
|
214
|
+
throw new Error("Cannot write color map undefined");
|
|
215
|
+
const c = Math.ceil(t.bitDepth / 8), E = new w.ByteStream(t.colorToIndexMap.size * c, !0);
|
|
216
|
+
let B;
|
|
217
|
+
switch (t.bitDepth) {
|
|
218
|
+
case 15:
|
|
219
|
+
B = b;
|
|
220
|
+
break;
|
|
221
|
+
case 16:
|
|
222
|
+
B = y;
|
|
223
|
+
break;
|
|
224
|
+
case 24:
|
|
225
|
+
B = T;
|
|
226
|
+
break;
|
|
227
|
+
case 32:
|
|
228
|
+
B = A;
|
|
229
|
+
break;
|
|
230
|
+
default:
|
|
231
|
+
throw new Error(`Unsupported bit depth for color map "${t.bitDepth}"`);
|
|
232
|
+
}
|
|
233
|
+
const P = Array.from(t.colorToIndexMap.entries()).sort((M, W) => M[1] - W[1]).map((M) => M[0]);
|
|
234
|
+
for (const M of P)
|
|
235
|
+
B(E, new Uint8Array([
|
|
236
|
+
M >> 24 & 255,
|
|
237
|
+
M >> 16 & 255,
|
|
238
|
+
M >> 8 & 255,
|
|
239
|
+
M & 255
|
|
240
|
+
]), 0);
|
|
241
|
+
return E.assertAtEnd(), E.array;
|
|
242
|
+
}
|
|
243
|
+
function l(n) {
|
|
244
|
+
const t = Math.ceil(n.bitDepth / 8), c = new w.ByteStream(n.image.width * n.image.height * t, !0);
|
|
245
|
+
let E = 0, B;
|
|
246
|
+
if (n.colorMap) {
|
|
247
|
+
const P = n.colorMap;
|
|
248
|
+
B = (M, W, e) => {
|
|
249
|
+
const r = P.colorToIndexMap.get((W[e] << 24) + (W[e + 1] << 16) + (W[e + 2] << 8) + W[e + 3]);
|
|
250
|
+
M.writeUint8(r);
|
|
251
|
+
};
|
|
252
|
+
} else
|
|
253
|
+
switch (n.bitDepth) {
|
|
254
|
+
case 8:
|
|
255
|
+
if (n.imageType === 3 || n.imageType === 11)
|
|
256
|
+
B = _;
|
|
257
|
+
else
|
|
258
|
+
throw new Error(`Unsupported image type (${n.imageType}) with bit depth (${n.bitDepth})`);
|
|
259
|
+
break;
|
|
260
|
+
case 15:
|
|
261
|
+
B = b;
|
|
262
|
+
break;
|
|
263
|
+
case 16:
|
|
264
|
+
n.imageType === 3 || n.imageType === 11 ? B = U : B = y;
|
|
265
|
+
break;
|
|
266
|
+
case 24:
|
|
267
|
+
B = T;
|
|
268
|
+
break;
|
|
269
|
+
case 32:
|
|
270
|
+
B = A;
|
|
271
|
+
break;
|
|
272
|
+
default:
|
|
273
|
+
throw new Error("NYI");
|
|
274
|
+
}
|
|
275
|
+
switch (n.options.screenOrigin ?? 0) {
|
|
276
|
+
case 0:
|
|
277
|
+
for (let P = n.image.height - 1; P >= 0; P--) {
|
|
278
|
+
E = n.image.width * P * 4;
|
|
279
|
+
for (let M = 0; M < n.image.width; M++)
|
|
280
|
+
B(c, n.image.data, E), E += 4;
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
case 1:
|
|
284
|
+
for (let P = n.image.height - 1; P >= 0; P--) {
|
|
285
|
+
E = (n.image.width * P + (n.image.width - 1)) * 4;
|
|
286
|
+
for (let M = 0; M < n.image.width; M++)
|
|
287
|
+
B(c, n.image.data, E), E -= 4;
|
|
288
|
+
}
|
|
289
|
+
break;
|
|
290
|
+
case 2:
|
|
291
|
+
for (let P = 0; P < n.image.height; P++) {
|
|
292
|
+
E = n.image.width * P * 4;
|
|
293
|
+
for (let M = 0; M < n.image.width; M++)
|
|
294
|
+
B(c, n.image.data, E), E += 4;
|
|
295
|
+
}
|
|
296
|
+
break;
|
|
297
|
+
case 3:
|
|
298
|
+
for (let P = 0; P < n.image.height; P++) {
|
|
299
|
+
E = (n.image.width * P + (n.image.width - 1)) * 4;
|
|
300
|
+
for (let M = 0; M < n.image.width; M++)
|
|
301
|
+
B(c, n.image.data, E), E -= 4;
|
|
302
|
+
}
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
return c.assertAtEnd(), n.imageType & 8 ? (0, h.encodeRunLengthEncoding)(n, c.array) : c.array;
|
|
306
|
+
}
|
|
307
|
+
function _(n, t, c) {
|
|
308
|
+
n.writeUint8(t[c]);
|
|
309
|
+
}
|
|
310
|
+
function b(n, t, c) {
|
|
311
|
+
n.writeUint16((t[c + 0] >> 3 & 31) << 10 | (t[c + 1] >> 3 & 31) << 5 | (t[c + 2] >> 3 & 31) << 0);
|
|
312
|
+
}
|
|
313
|
+
function y(n, t, c) {
|
|
314
|
+
n.writeUint16((t[c + 0] >> 3 & 31) << 10 | (t[c + 1] >> 3 & 31) << 5 | (t[c + 2] >> 3 & 31) << 0 | (t[c + 3] === 255 ? 32768 : 0));
|
|
315
|
+
}
|
|
316
|
+
function U(n, t, c) {
|
|
317
|
+
n.writeUint8(t[c]), n.writeUint8(t[c + 3]);
|
|
318
|
+
}
|
|
319
|
+
function T(n, t, c) {
|
|
320
|
+
n.writeUint8(t[c + 2]), n.writeUint8(t[c + 1]), n.writeUint8(t[c + 0]);
|
|
321
|
+
}
|
|
322
|
+
function A(n, t, c) {
|
|
323
|
+
n.writeUint8(t[c + 2]), n.writeUint8(t[c + 1]), n.writeUint8(t[c + 0]), n.writeUint8(t[c + 3]);
|
|
324
|
+
}
|
|
325
|
+
return q;
|
|
326
|
+
}
|
|
327
|
+
var Me = Ae(), z = {}, C = {}, ie;
|
|
328
|
+
function ue() {
|
|
329
|
+
if (ie) return C;
|
|
330
|
+
ie = 1, Object.defineProperty(C, "__esModule", { value: !0 }), C.handleWarning = C.DecodeWarning = C.DecodeError = void 0;
|
|
331
|
+
class i extends Error {
|
|
332
|
+
constructor(f, v, o) {
|
|
333
|
+
super(v), this.offset = o, this.partiallyDecodedImage = {
|
|
334
|
+
details: {
|
|
335
|
+
header: f.header,
|
|
336
|
+
footer: f.footer,
|
|
337
|
+
imageId: f.identificationField,
|
|
338
|
+
developerDirectory: f.developerDirectory,
|
|
339
|
+
extensionArea: f.extensionArea
|
|
340
|
+
},
|
|
341
|
+
warnings: f.warnings
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
C.DecodeError = i;
|
|
346
|
+
class w extends Error {
|
|
347
|
+
constructor(f, v) {
|
|
348
|
+
super(f), this.offset = v;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
C.DecodeWarning = w;
|
|
352
|
+
function h(u, f) {
|
|
353
|
+
if (u.options.strictMode)
|
|
354
|
+
throw f;
|
|
355
|
+
u.warnings.push(f);
|
|
356
|
+
}
|
|
357
|
+
return C.handleWarning = h, C;
|
|
358
|
+
}
|
|
359
|
+
var N = {}, oe;
|
|
360
|
+
function Pe() {
|
|
361
|
+
if (oe) return N;
|
|
362
|
+
oe = 1, Object.defineProperty(N, "__esModule", { value: !0 }), N.ByteStreamReader = void 0;
|
|
363
|
+
class i {
|
|
364
|
+
constructor(h, u) {
|
|
365
|
+
this.data = h, this._le = u, this.offset = 0, this.view = new DataView(h.buffer, h.byteOffset, h.byteLength);
|
|
366
|
+
}
|
|
367
|
+
readUint8() {
|
|
368
|
+
return this.view.getUint8(this.offset++);
|
|
369
|
+
}
|
|
370
|
+
readUint16() {
|
|
371
|
+
const h = this.view.getUint16(this.offset, this._le);
|
|
372
|
+
return this.offset += 2, h;
|
|
373
|
+
}
|
|
374
|
+
readUint32() {
|
|
375
|
+
const h = this.view.getUint32(this.offset, this._le);
|
|
376
|
+
return this.offset += 4, h;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return N.ByteStreamReader = i, N;
|
|
380
|
+
}
|
|
381
|
+
var X = {}, ae;
|
|
382
|
+
function Ie() {
|
|
383
|
+
if (ae) return X;
|
|
384
|
+
ae = 1, Object.defineProperty(X, "__esModule", { value: !0 }), X.readText = void 0;
|
|
385
|
+
const i = ue();
|
|
386
|
+
function w(h, u, f, v) {
|
|
387
|
+
const o = [];
|
|
388
|
+
let l = 0, _ = 0;
|
|
389
|
+
const b = h.reader.offset;
|
|
390
|
+
for (; _ < f; _++) {
|
|
391
|
+
try {
|
|
392
|
+
l = h.reader.view.getUint8(h.reader.offset);
|
|
393
|
+
} catch (y) {
|
|
394
|
+
throw y instanceof Error && y.message === "Offset is outside the bounds of the DataView" && (0, i.handleWarning)(h, new i.DecodeWarning("EOF while reading text", h.reader.offset)), y;
|
|
395
|
+
}
|
|
396
|
+
if (!v && l === 0)
|
|
397
|
+
break;
|
|
398
|
+
h.reader.offset++, o.push(l);
|
|
399
|
+
}
|
|
400
|
+
return h.reader.offset = b + f, u ? u.decode(new Uint8Array(o)) : String.fromCharCode(...o);
|
|
401
|
+
}
|
|
402
|
+
return X.readText = w, X;
|
|
403
|
+
}
|
|
404
|
+
var S = {}, de;
|
|
405
|
+
function _e() {
|
|
406
|
+
if (de) return S;
|
|
407
|
+
de = 1, Object.defineProperty(S, "__esModule", { value: !0 }), S.isValidBitDepth = S.isValidColorMapDepth = S.isValidImageType = void 0;
|
|
408
|
+
function i(u) {
|
|
409
|
+
return u === 1 || u === 2 || u === 3 || u === 9 || u === 10 || u === 11;
|
|
410
|
+
}
|
|
411
|
+
S.isValidImageType = i;
|
|
412
|
+
function w(u) {
|
|
413
|
+
return u === 15 || u === 16 || u === 24 || u === 32;
|
|
414
|
+
}
|
|
415
|
+
S.isValidColorMapDepth = w;
|
|
416
|
+
function h(u, f) {
|
|
417
|
+
return f === 1 || f === 9 ? u === 8 : f === 3 || f === 11 ? u === 8 || u === 16 : u === 15 || u === 16 || u === 24 || u === 32;
|
|
418
|
+
}
|
|
419
|
+
return S.isValidBitDepth = h, S;
|
|
420
|
+
}
|
|
421
|
+
var se;
|
|
422
|
+
function Be() {
|
|
423
|
+
if (se) return z;
|
|
424
|
+
se = 1, Object.defineProperty(z, "__esModule", { value: !0 }), z.decodeTga = void 0;
|
|
425
|
+
const i = ue(), w = Pe(), h = Ie(), u = _e();
|
|
426
|
+
async function f(e, r = {}) {
|
|
427
|
+
const a = {
|
|
428
|
+
reader: new w.ByteStreamReader(e, !0),
|
|
429
|
+
hasAlpha: !1,
|
|
430
|
+
ambiguousAlpha: !1,
|
|
431
|
+
options: r,
|
|
432
|
+
warnings: []
|
|
433
|
+
}, s = v(a), d = {
|
|
434
|
+
...a,
|
|
435
|
+
header: s
|
|
436
|
+
};
|
|
437
|
+
d.identificationField = (0, h.readText)(d, void 0, d.header.idLength);
|
|
438
|
+
const p = d.reader.offset;
|
|
439
|
+
return d.footer = W(d), d.extensionArea = E(d), d.developerDirectory = B(d), d.reader.offset = p, d.header.colorMap?.type === 1 && (d.colorMap = o(d, d.header.colorMap)), d.hasAlpha = d.colorMap && d.header.colorMap?.depth === 32 || (d.header.attributeBitsPerPixel > 0 || d.header.bitDepth === 32) && (d.extensionArea === void 0 || d.extensionArea.attributesType > 2), d.ambiguousAlpha = d.hasAlpha && d.header.attributeBitsPerPixel === 0, d.image = l(d, d.reader.offset), {
|
|
440
|
+
image: d.image,
|
|
441
|
+
details: {
|
|
442
|
+
header: d.header,
|
|
443
|
+
imageId: d.identificationField,
|
|
444
|
+
footer: d.footer,
|
|
445
|
+
extensionArea: d.extensionArea,
|
|
446
|
+
developerDirectory: d.developerDirectory
|
|
447
|
+
},
|
|
448
|
+
warnings: d.warnings
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
z.decodeTga = f;
|
|
452
|
+
function v(e) {
|
|
453
|
+
const r = e.reader.readUint8(), a = e.reader.readUint8();
|
|
454
|
+
let s;
|
|
455
|
+
a === 0 || a === 1 ? s = a : ((0, i.handleWarning)(e, new i.DecodeWarning("Color map type unrecognized", e.reader.offset - 1)), s = 2);
|
|
456
|
+
const d = e.reader.readUint8();
|
|
457
|
+
if (!(0, u.isValidImageType)(d))
|
|
458
|
+
throw new i.DecodeError(e, `Invalid image type "${d}"`, e.reader.offset - 1);
|
|
459
|
+
s === 1 && d !== 1 && d !== 9 && (0, i.handleWarning)(e, new i.DecodeWarning(`Image type "${d}" cannot have a color map`, e.reader.offset - 2));
|
|
460
|
+
const p = e.reader.readUint16(), g = e.reader.readUint16(), I = e.reader.readUint8();
|
|
461
|
+
if (s === 1 && (p >= g && (0, i.handleWarning)(e, new i.DecodeWarning(`Color map origin "${p}" is greater than color map length "${g}"`, e.reader.offset - 5)), !(0, u.isValidColorMapDepth)(I)))
|
|
462
|
+
throw new i.DecodeError(e, `Unsupported color map bit depth "${I}"`, e.reader.offset - 1);
|
|
463
|
+
const k = e.reader.readUint16(), m = e.reader.readUint16(), V = e.reader.readUint16(), Y = e.reader.readUint16(), j = e.reader.readUint8();
|
|
464
|
+
if (!(0, u.isValidBitDepth)(j, d))
|
|
465
|
+
throw new i.DecodeError(e, `Unsupported TGA bit depth "${j}" with image type ${d}`, 16);
|
|
466
|
+
const D = e.reader.readUint8(), J = (D & 15) >> 0, $ = (D & 48) >> 4;
|
|
467
|
+
return $ === 1 && (0, i.handleWarning)(e, new i.DecodeWarning("This image is encoded using a bottom right screen origin, many image editors won't read this correctly", e.reader.offset - 1)), $ === 3 && (0, i.handleWarning)(e, new i.DecodeWarning("This image is encoded using a top right screen origin, many image editors won't read this correctly", e.reader.offset - 1)), {
|
|
468
|
+
idLength: r,
|
|
469
|
+
colorMap: s !== 0 ? {
|
|
470
|
+
type: s,
|
|
471
|
+
depth: I,
|
|
472
|
+
length: g,
|
|
473
|
+
origin: p
|
|
474
|
+
} : void 0,
|
|
475
|
+
imageType: d,
|
|
476
|
+
origin: {
|
|
477
|
+
x: k,
|
|
478
|
+
y: m
|
|
479
|
+
},
|
|
480
|
+
width: V,
|
|
481
|
+
height: Y,
|
|
482
|
+
bitDepth: j,
|
|
483
|
+
imageDescriptor: D,
|
|
484
|
+
attributeBitsPerPixel: J,
|
|
485
|
+
screenOrigin: $
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
function o(e, r) {
|
|
489
|
+
const a = e.reader.offset, s = Math.ceil(r.depth / 8);
|
|
490
|
+
e.reader.offset += r.length * s;
|
|
491
|
+
let d;
|
|
492
|
+
switch (r.depth) {
|
|
493
|
+
case 15:
|
|
494
|
+
d = T;
|
|
495
|
+
break;
|
|
496
|
+
case 16:
|
|
497
|
+
e.hasAlpha ? d = A : d = T;
|
|
498
|
+
break;
|
|
499
|
+
case 24:
|
|
500
|
+
d = n;
|
|
501
|
+
break;
|
|
502
|
+
case 32:
|
|
503
|
+
d = t;
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
return (p, g, I, k) => {
|
|
507
|
+
const m = I.getUint8(k);
|
|
508
|
+
return d(p, g, e.reader.view, a + m * s), 1;
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
function l(e, r) {
|
|
512
|
+
const a = {
|
|
513
|
+
width: e.header.width,
|
|
514
|
+
height: e.header.height,
|
|
515
|
+
data: new Uint8Array(e.header.width * e.header.height * 4)
|
|
516
|
+
};
|
|
517
|
+
let s;
|
|
518
|
+
if (e.colorMap)
|
|
519
|
+
s = e.colorMap;
|
|
520
|
+
else
|
|
521
|
+
switch (e.header.bitDepth) {
|
|
522
|
+
case 8:
|
|
523
|
+
s = b;
|
|
524
|
+
break;
|
|
525
|
+
case 15:
|
|
526
|
+
s = T;
|
|
527
|
+
break;
|
|
528
|
+
case 16:
|
|
529
|
+
e.header.imageType === 11 || e.header.imageType === 3 ? s = y : e.hasAlpha ? s = A : s = T;
|
|
530
|
+
break;
|
|
531
|
+
case 24:
|
|
532
|
+
s = n;
|
|
533
|
+
break;
|
|
534
|
+
case 32:
|
|
535
|
+
e.hasAlpha ? s = t : s = c;
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
let d = e.reader.view;
|
|
539
|
+
if (e.header.imageType & 8) {
|
|
540
|
+
const p = _(e);
|
|
541
|
+
d = new DataView(p.buffer, p.byteOffset, p.length), r = 0;
|
|
542
|
+
}
|
|
543
|
+
switch (e.header.screenOrigin) {
|
|
544
|
+
case 0: {
|
|
545
|
+
let p = 0;
|
|
546
|
+
for (let g = a.height - 1; g >= 0; g--) {
|
|
547
|
+
p = e.header.width * g * 4;
|
|
548
|
+
for (let I = 0; I < a.width; I++)
|
|
549
|
+
r += s(a.data, p, d, r), p += 4;
|
|
550
|
+
}
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
case 1: {
|
|
554
|
+
let p = 0;
|
|
555
|
+
for (let g = a.height - 1; g >= 0; g--) {
|
|
556
|
+
p = (e.header.width * g + (e.header.width - 1)) * 4;
|
|
557
|
+
for (let I = 0; I < a.width; I++)
|
|
558
|
+
r += s(a.data, p, d, r), p -= 4;
|
|
559
|
+
}
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
case 2: {
|
|
563
|
+
let p = 0;
|
|
564
|
+
for (let g = 0; g < a.height; g++)
|
|
565
|
+
for (let I = 0; I < a.width; I++)
|
|
566
|
+
r += s(a.data, p, d, r), p += 4;
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
case 3: {
|
|
570
|
+
let p = 0;
|
|
571
|
+
for (let g = 0; g < a.height; g++) {
|
|
572
|
+
p = (e.header.width * g + (e.header.width - 1)) * 4;
|
|
573
|
+
for (let I = 0; I < a.width; I++)
|
|
574
|
+
r += s(a.data, p, d, r), p -= 4;
|
|
575
|
+
}
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
if (e.ambiguousAlpha && !e.options.strictMode && e.options.detectAmbiguousAlphaChannel) {
|
|
580
|
+
let p = !1;
|
|
581
|
+
for (let g = 3; g < a.width * a.height * 4; g += 4)
|
|
582
|
+
a.data[g] > 0 && (p = !0);
|
|
583
|
+
if (!p) {
|
|
584
|
+
(0, i.handleWarning)(e, new i.DecodeWarning("Image has ambiguous alpha and is fully transparent, alpha has been disabled", -1));
|
|
585
|
+
for (let g = 3; g < a.width * a.height * 4; g += 4)
|
|
586
|
+
a.data[g] = 255;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return a;
|
|
590
|
+
}
|
|
591
|
+
function _(e) {
|
|
592
|
+
const r = Math.ceil(e.header.bitDepth / 8), a = new Uint8Array(e.header.width * e.header.height * r);
|
|
593
|
+
let s = 0, d = 0, p = 0, g = 0, I = 0;
|
|
594
|
+
for (; p < a.length; )
|
|
595
|
+
if (s = e.reader.readUint8(), d = (s & 127) + 1, s & 128) {
|
|
596
|
+
for (g = 0; g < r; g++)
|
|
597
|
+
for (s = e.reader.readUint8(), I = 0; I < d; I++)
|
|
598
|
+
a[p + I * r + g] = s;
|
|
599
|
+
p += d * r;
|
|
600
|
+
} else {
|
|
601
|
+
d *= r;
|
|
602
|
+
for (let k = 0; k < d; k++)
|
|
603
|
+
a[p++] = e.reader.readUint8();
|
|
604
|
+
}
|
|
605
|
+
return a;
|
|
606
|
+
}
|
|
607
|
+
function b(e, r, a, s) {
|
|
608
|
+
return e[r] = a.getUint8(s), e[r + 1] = e[r], e[r + 2] = e[r], e[r + 3] = 255, 1;
|
|
609
|
+
}
|
|
610
|
+
function y(e, r, a, s) {
|
|
611
|
+
return e[r] = a.getUint8(s), e[r + 1] = e[r], e[r + 2] = e[r], e[r + 3] = a.getUint8(s + 1), 2;
|
|
612
|
+
}
|
|
613
|
+
let U = 0;
|
|
614
|
+
function T(e, r, a, s) {
|
|
615
|
+
return U = a.getUint16(s, !0), e[r] = U >> 10 & 31, e[r + 1] = U >> 5 & 31, e[r + 2] = U & 31, e[r] = e[r] << 3 | e[r] >> 2, e[r + 1] = e[r + 1] << 3 | e[r + 1] >> 2, e[r + 2] = e[r + 2] << 3 | e[r + 2] >> 2, e[r + 3] = 255, 2;
|
|
616
|
+
}
|
|
617
|
+
function A(e, r, a, s) {
|
|
618
|
+
return U = a.getUint16(s, !0), e[r] = U >> 10 & 31, e[r + 1] = U >> 5 & 31, e[r + 2] = U & 31, e[r] = e[r] << 3 | e[r] >> 2, e[r + 1] = e[r + 1] << 3 | e[r + 1] >> 2, e[r + 2] = e[r + 2] << 3 | e[r + 2] >> 2, e[r + 3] = U & 32768 ? 0 : 255, 2;
|
|
619
|
+
}
|
|
620
|
+
function n(e, r, a, s) {
|
|
621
|
+
return e[r] = a.getUint8(s + 2), e[r + 1] = a.getUint8(s + 1), e[r + 2] = a.getUint8(s), e[r + 3] = 255, 3;
|
|
622
|
+
}
|
|
623
|
+
function t(e, r, a, s) {
|
|
624
|
+
return e[r] = a.getUint8(s + 2), e[r + 1] = a.getUint8(s + 1), e[r + 2] = a.getUint8(s), e[r + 3] = a.getUint8(s + 3), 4;
|
|
625
|
+
}
|
|
626
|
+
function c(e, r, a, s) {
|
|
627
|
+
return e[r] = a.getUint8(s + 2), e[r + 1] = a.getUint8(s + 1), e[r + 2] = a.getUint8(s), e[r + 3] = 255, 4;
|
|
628
|
+
}
|
|
629
|
+
function E(e) {
|
|
630
|
+
if (e.footer?.extensionAreaOffset === void 0 || e.footer.extensionAreaOffset === 0)
|
|
631
|
+
return;
|
|
632
|
+
e.reader.offset = e.footer.extensionAreaOffset;
|
|
633
|
+
const r = e.reader.readUint16();
|
|
634
|
+
r !== 495 && (0, i.handleWarning)(e, new i.DecodeWarning("TGA file is a version other than v2", e.reader.offset - 2));
|
|
635
|
+
const a = (0, h.readText)(e, void 0, 41).trim() || void 0, s = (0, h.readText)(e, void 0, 324).trim() || void 0, d = P(e), p = (0, h.readText)(e, void 0, 41).trim() || void 0, g = M(e), I = (0, h.readText)(e, void 0, 41).trim() || void 0, k = e.reader.readUint8() / 100, m = (0, h.readText)(e, void 0, 2);
|
|
636
|
+
let V;
|
|
637
|
+
k === 0 && (m === " " || m.length === 0) ? V = void 0 : V = `${k}${m}`;
|
|
638
|
+
const Y = e.reader.readUint8(), j = e.reader.readUint8(), D = e.reader.readUint8(), J = e.reader.readUint8();
|
|
639
|
+
let $;
|
|
640
|
+
Y === 0 && j === 0 && D === 0 && J === 0 ? $ = void 0 : $ = new Uint8Array([j, D, J, Y]);
|
|
641
|
+
const ce = e.reader.readUint16(), H = e.reader.readUint16();
|
|
642
|
+
let K;
|
|
643
|
+
H === 0 ? K = void 0 : K = ce / H;
|
|
644
|
+
const we = e.reader.readUint16(), O = e.reader.readUint16();
|
|
645
|
+
let Q;
|
|
646
|
+
O === 0 ? Q = void 0 : Q = we / O;
|
|
647
|
+
const pe = e.reader.readUint32(), ge = e.reader.readUint32(), ye = e.reader.readUint32(), Ue = e.reader.readUint8();
|
|
648
|
+
return {
|
|
649
|
+
extensionSize: r,
|
|
650
|
+
authorName: a,
|
|
651
|
+
authorComments: s,
|
|
652
|
+
dateTimestamp: d,
|
|
653
|
+
jobName: p,
|
|
654
|
+
jobTime: g,
|
|
655
|
+
softwareId: I,
|
|
656
|
+
softwareVersion: V,
|
|
657
|
+
keyColor: $,
|
|
658
|
+
aspectRatio: K,
|
|
659
|
+
gamma: Q,
|
|
660
|
+
colorCorrectionOffset: pe,
|
|
661
|
+
postageStampOffset: ge,
|
|
662
|
+
scanLineOffset: ye,
|
|
663
|
+
attributesType: Ue
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
function B(e) {
|
|
667
|
+
if (e.footer?.developerDirectoryOffset === void 0 || e.footer.developerDirectoryOffset === 0)
|
|
668
|
+
return [];
|
|
669
|
+
e.reader.offset = e.footer.developerDirectoryOffset;
|
|
670
|
+
const r = e.reader.readUint16(), a = [];
|
|
671
|
+
for (let s = 0; s < r; s++) {
|
|
672
|
+
const d = e.reader.readUint16(), p = e.reader.readUint32(), g = e.reader.readUint32();
|
|
673
|
+
a.push({ tag: d, offset: p, length: g });
|
|
674
|
+
}
|
|
675
|
+
return a;
|
|
676
|
+
}
|
|
677
|
+
function P(e) {
|
|
678
|
+
const r = e.reader.readUint16(), a = e.reader.readUint16(), s = e.reader.readUint16(), d = e.reader.readUint16(), p = e.reader.readUint16(), g = e.reader.readUint16();
|
|
679
|
+
if (!(r === 0 && a === 0 && s === 0 && d === 0 && p === 0 && g === 0))
|
|
680
|
+
return new Date(s, r, a, d, p, g);
|
|
681
|
+
}
|
|
682
|
+
function M(e) {
|
|
683
|
+
const r = e.reader.readUint16(), a = e.reader.readUint16(), s = e.reader.readUint16();
|
|
684
|
+
if (!(r === 0 && a === 0 && s === 0))
|
|
685
|
+
return { hours: r, minutes: a, seconds: s };
|
|
686
|
+
}
|
|
687
|
+
function W(e) {
|
|
688
|
+
if (e.reader.offset = e.reader.view.byteLength - 26 + 8, (0, h.readText)(e, void 0, 17) !== "TRUEVISION-XFILE." || e.reader.readUint8() !== 0)
|
|
689
|
+
return {
|
|
690
|
+
extensionAreaOffset: 0,
|
|
691
|
+
developerDirectoryOffset: 0
|
|
692
|
+
};
|
|
693
|
+
e.reader.offset = e.reader.view.byteLength - 26;
|
|
694
|
+
let a = e.reader.readUint32();
|
|
695
|
+
a >= e.reader.view.byteLength && ((0, i.handleWarning)(e, new i.DecodeWarning(`Extension area offset "${a}" is invalid`, e.reader.offset - 4)), a = 0);
|
|
696
|
+
let s = e.reader.readUint32();
|
|
697
|
+
return s >= e.reader.view.byteLength && ((0, i.handleWarning)(e, new i.DecodeWarning(`Developer directory offset "${s}" is invalid`, e.reader.offset - 4)), s = 0), {
|
|
698
|
+
extensionAreaOffset: a,
|
|
699
|
+
developerDirectoryOffset: s
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
return z;
|
|
703
|
+
}
|
|
704
|
+
var We = Be();
|
|
705
|
+
function fe(i, w, h) {
|
|
706
|
+
if (!Number.isSafeInteger(w) || !Number.isSafeInteger(h) || w < 1 || h < 1 || w > 65535 || h > 65535 || w * h > be || i.length !== w * h * 4)
|
|
707
|
+
throw new Error("TGA图片像素超过限制或尺寸无效");
|
|
708
|
+
}
|
|
709
|
+
function Z(i, w, h, u) {
|
|
710
|
+
let f = 18, v = 18, o = 0;
|
|
711
|
+
for (; o < w * h; ) {
|
|
712
|
+
if (f >= i.length) throw new Error("TGA输出数据截断");
|
|
713
|
+
const l = i[f++], _ = (l & 128) !== 0;
|
|
714
|
+
let b = (l & 127) + 1;
|
|
715
|
+
const y = _ ? 4 : b * 4;
|
|
716
|
+
if (o + b > w * h || f + y > i.length)
|
|
717
|
+
throw new Error("TGA输出数据截断或像素溢出");
|
|
718
|
+
let U = f;
|
|
719
|
+
for (; b > 0; ) {
|
|
720
|
+
const T = Math.min(b, w - o % w), A = _ ? 4 : T * 4;
|
|
721
|
+
if (v + 1 + A > le) throw new Error("TGA图片大小超过限制");
|
|
722
|
+
u && (u[v] = (_ ? 128 : 0) | T - 1, u.set(i.subarray(U, U + A), v + 1)), v += 1 + A, _ || (U += A), o += T, b -= T;
|
|
723
|
+
}
|
|
724
|
+
f += y;
|
|
725
|
+
}
|
|
726
|
+
if (f !== i.length) throw new Error("TGA输出数据长度无效");
|
|
727
|
+
return v;
|
|
728
|
+
}
|
|
729
|
+
async function ke(i, w, h, u) {
|
|
730
|
+
if (fe(w, h, u), i.length < 18 || i.length > le)
|
|
731
|
+
throw new Error("TGA图片大小超过限制或为空");
|
|
732
|
+
if (i[0] !== 0 || i[1] !== 0 || i[2] !== 10 || i[16] !== 32 || i[17] !== 40 || (i[12] | i[13] << 8) !== h || (i[14] | i[15] << 8) !== u)
|
|
733
|
+
throw new Error("TGA输出格式或尺寸校验失败");
|
|
734
|
+
if (Z(i, h, u) !== i.length)
|
|
735
|
+
throw new Error("TGA输出RLE数据跨越扫描行");
|
|
736
|
+
const { image: f } = await We.decodeTga(i, { strictMode: !0 });
|
|
737
|
+
if (f.width !== h || f.height !== u || f.data.length !== w.length || !f.data.every((v, o) => v === w[o]))
|
|
738
|
+
throw new Error("TGA输出像素校验失败");
|
|
739
|
+
}
|
|
740
|
+
async function Ce(i, w, h) {
|
|
741
|
+
fe(i, w, h);
|
|
742
|
+
const { data: u } = await Me.encodeTga(
|
|
743
|
+
{ data: new Uint8Array(i), width: w, height: h },
|
|
744
|
+
// RLE growth on colorful images is valid; verify the complete output below.
|
|
745
|
+
{ imageType: 10, bitDepth: 32, screenOrigin: 2, strictMode: !1 }
|
|
746
|
+
), f = new Uint8Array(Z(u, w, h));
|
|
747
|
+
return f.set(u.subarray(0, 18)), Z(u, w, h, f), await ke(f, i, w, h), f;
|
|
748
|
+
}
|
|
749
|
+
export {
|
|
750
|
+
Ce as encodeTga,
|
|
751
|
+
ke as verifyTga
|
|
752
|
+
};
|