Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

Commit 7f8731b

Browse files
committed
fix: fix bug with matrix size check
1 parent 1a96bf3 commit 7f8731b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/geometry/transform.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ export function transform(
6262
fullImage,
6363
} = options;
6464
let { width = image.width, height = image.height } = options;
65+
66+
if (!isValidMatrix(transformMatrix)) {
67+
throw new TypeError(
68+
`transformation matrix must be 2x3 or 3x3. Received ${transformMatrix.length}x${transformMatrix[1].length}`,
69+
);
70+
}
71+
if (transformMatrix.length === 2) {
72+
transformMatrix.push([0, 0, 1]);
73+
}
74+
6575
if (fullImage) {
6676
transformMatrix = transformMatrix.map((row) => row.slice());
6777
transformMatrix[0][2] = 0;
@@ -126,15 +136,6 @@ export function transform(
126136
height = Math.round(height);
127137
}
128138

129-
if (!isValidMatrix(transformMatrix)) {
130-
throw new TypeError(
131-
`transformation matrix must be 2x3 or 3x3. Received ${transformMatrix.length}x${transformMatrix[1].length}`,
132-
);
133-
}
134-
if (transformMatrix.length === 2) {
135-
transformMatrix.push([0, 0, 1]);
136-
}
137-
138139
if (!options.inverse) {
139140
transformMatrix = inverse(new Matrix(transformMatrix)).to2DArray();
140141
}

0 commit comments

Comments
 (0)