server-json/node_modules/exifreader/src/byte-order.js
2024-11-01 08:00:42 +00:00

21 lines
655 B
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
const LITTLE_ENDIAN = 0x4949;
const BIG_ENDIAN = 0x4d4d;
export default {
BIG_ENDIAN,
LITTLE_ENDIAN,
getByteOrder
};
function getByteOrder(dataView, tiffHeaderOffset) {
if (dataView.getUint16(tiffHeaderOffset) === LITTLE_ENDIAN) {
return LITTLE_ENDIAN;
} else if (dataView.getUint16(tiffHeaderOffset) === BIG_ENDIAN) {
return BIG_ENDIAN;
}
throw new Error('Illegal byte order value. Faulty image.');
}