@bb-studio/exr 0.1.3 → 0.2.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/README.md +14 -1
- package/dist/browser/dwaDecodeWorker.js.map +1 -1
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.js +22 -5
- package/dist/browser/index.js.map +1 -1
- package/dist/index.cjs +22 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2807,7 +2807,7 @@ function toNumberOffset(low, high) {
|
|
|
2807
2807
|
}
|
|
2808
2808
|
return Number(combined);
|
|
2809
2809
|
}
|
|
2810
|
-
function buildChannelMeta(part) {
|
|
2810
|
+
function buildChannelMeta(part, selectedChannelNames) {
|
|
2811
2811
|
if (!part.dataWindow) return [];
|
|
2812
2812
|
const { xMin, xMax, yMin, yMax } = part.dataWindow;
|
|
2813
2813
|
return part.channels.map((channel) => {
|
|
@@ -2818,8 +2818,10 @@ function buildChannelMeta(part) {
|
|
|
2818
2818
|
const sampledWidth = countSamplesInRange4(xMin, xMax, xSampling);
|
|
2819
2819
|
const sampledHeight = countSamplesInRange4(yMin, yMax, ySampling);
|
|
2820
2820
|
const bytesPerSample = channel.pixelType === 1 ? 2 : 4;
|
|
2821
|
+
const selected = selectedChannelNames?.has(channel.name) ?? true;
|
|
2821
2822
|
return {
|
|
2822
2823
|
channel,
|
|
2824
|
+
selected,
|
|
2823
2825
|
pixelType: channel.pixelType,
|
|
2824
2826
|
ySampling,
|
|
2825
2827
|
bytesPerSample,
|
|
@@ -2828,7 +2830,7 @@ function buildChannelMeta(part) {
|
|
|
2828
2830
|
sampledHeight,
|
|
2829
2831
|
sampleOriginX,
|
|
2830
2832
|
sampleOriginY,
|
|
2831
|
-
data: new Float32Array(sampledWidth * sampledHeight)
|
|
2833
|
+
data: selected ? new Float32Array(sampledWidth * sampledHeight) : new Float32Array(0)
|
|
2832
2834
|
};
|
|
2833
2835
|
});
|
|
2834
2836
|
}
|
|
@@ -2980,7 +2982,18 @@ function decodeExrPart(bufferInput, structure, options) {
|
|
|
2980
2982
|
ms: (nowMs2() - tOffsets).toFixed(3)
|
|
2981
2983
|
}
|
|
2982
2984
|
});
|
|
2983
|
-
const
|
|
2985
|
+
const selectedChannelNames = options.channelNames ? new Set(options.channelNames) : void 0;
|
|
2986
|
+
if (selectedChannelNames) {
|
|
2987
|
+
for (const name of selectedChannelNames) {
|
|
2988
|
+
if (!part.channels.some((channel) => channel.name === name)) {
|
|
2989
|
+
throw new ExrError("CHANNEL_NOT_FOUND", `Channel ${name} was not found in EXR part.`, {
|
|
2990
|
+
partId: part.id,
|
|
2991
|
+
channel: name
|
|
2992
|
+
});
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
}
|
|
2996
|
+
const channelMeta = buildChannelMeta(part, selectedChannelNames);
|
|
2984
2997
|
const zipScratch = {
|
|
2985
2998
|
inflate: new Uint8Array(0),
|
|
2986
2999
|
output: new Uint8Array(0)
|
|
@@ -3087,8 +3100,10 @@ function decodeExrPart(bufferInput, structure, options) {
|
|
|
3087
3100
|
blockPointer += byteLength;
|
|
3088
3101
|
continue;
|
|
3089
3102
|
}
|
|
3090
|
-
|
|
3091
|
-
|
|
3103
|
+
if (meta.selected) {
|
|
3104
|
+
const rowOffset = sampledRow * meta.sampledWidth;
|
|
3105
|
+
decodeRowIntoChannel(meta, blockData, blockPointer, rowOffset, blockView);
|
|
3106
|
+
}
|
|
3092
3107
|
blockPointer += byteLength;
|
|
3093
3108
|
}
|
|
3094
3109
|
}
|
|
@@ -3108,6 +3123,7 @@ function decodeExrPart(bufferInput, structure, options) {
|
|
|
3108
3123
|
}
|
|
3109
3124
|
const decodedChannels = {};
|
|
3110
3125
|
for (const meta of channelMeta) {
|
|
3126
|
+
if (!meta.selected) continue;
|
|
3111
3127
|
decodedChannels[meta.channel.name] = {
|
|
3112
3128
|
pixelType: meta.channel.pixelType,
|
|
3113
3129
|
xSampling: meta.channel.xSampling,
|
|
@@ -4954,6 +4970,7 @@ function writeExr(input, options = {}) {
|
|
|
4954
4970
|
|
|
4955
4971
|
// src/writer/encodeExrRgba.ts
|
|
4956
4972
|
function pixelTypeForPrecision(precision) {
|
|
4973
|
+
if (precision === "uint") return 0;
|
|
4957
4974
|
return precision === "half" ? 1 : 2;
|
|
4958
4975
|
}
|
|
4959
4976
|
function extractRgbaChannel(rgba, offset) {
|