@eris/exif
Advanced tools
Comparing version 0.4.2-alpha.9 to 0.4.2-alpha.10
@@ -77,3 +77,3 @@ "use strict"; | ||
const dataReader = reader.readAsReader(4); | ||
log.verbose(`read tag ${tag}`, dataReader); | ||
log.verbose(`read tag ${tags_1.getFriendlyName(tag)} (${tag})`); | ||
return new IFDEntry(startOffset, tag, dataType, length, dataReader); | ||
@@ -80,0 +80,0 @@ } |
@@ -11,2 +11,8 @@ "use strict"; | ||
const ifd_entry_1 = require("./ifd-entry"); | ||
const TIFF_MAGIC_VERSION = 42; | ||
/** | ||
* Olympus raw files are basically TIFFs but with a replaced magic text | ||
* @see https://libopenraw.freedesktop.org/formats/orf/ | ||
*/ | ||
const OLYMPUS_MAGIC_VERSION = 0x4f52; | ||
const log = log_1.createLogger('decoder'); | ||
@@ -30,7 +36,7 @@ class TIFFDecoder { | ||
else { | ||
throw new Error('Unrecognized format'); | ||
throw new Error('Unrecognized TIFF format'); | ||
} | ||
const version = this._reader.read(2); | ||
if (version !== 42) { | ||
throw new Error(`Unrecognized format: ${version.toString(16)}`); | ||
if (version !== TIFF_MAGIC_VERSION && version !== OLYMPUS_MAGIC_VERSION) { | ||
throw new Error(`Unrecognized TIFF version: ${version.toString(16)}`); | ||
} | ||
@@ -37,0 +43,0 @@ } |
import { JPEGDecoder } from './decoder/jpeg-decoder'; | ||
import { FujiDecoder } from './decoder/fuji-decoder'; | ||
import { TIFFDecoder } from './decoder/tiff-decoder'; | ||
@@ -10,3 +11,3 @@ import { XMPDecoder } from './decoder/xmp-decoder'; | ||
export declare function parse(bufferOrDecoder: IBufferLike | IDecoder): INormalizedMetadata; | ||
export { normalizeMetadata, TIFFDecoder, JPEGDecoder, XMPDecoder, TIFFEncoder, XMPEncoder }; | ||
export { normalizeMetadata, TIFFDecoder, FujiDecoder, JPEGDecoder, XMPDecoder, TIFFEncoder, XMPEncoder, }; | ||
export { IGenericMetadata, INormalizedMetadata, IParsedLens, IFDTagName } from './utils/types'; |
@@ -5,2 +5,4 @@ "use strict"; | ||
exports.JPEGDecoder = jpeg_decoder_1.JPEGDecoder; | ||
const fuji_decoder_1 = require("./decoder/fuji-decoder"); | ||
exports.FujiDecoder = fuji_decoder_1.FujiDecoder; | ||
const tiff_decoder_1 = require("./decoder/tiff-decoder"); | ||
@@ -22,2 +24,9 @@ exports.TIFFDecoder = tiff_decoder_1.TIFFDecoder; | ||
} | ||
function isLikelyFuji(buffer) { | ||
for (let i = 0; i < fuji_decoder_1.FUJI_MAGIC_STRING.length; i++) { | ||
if (buffer[i] !== fuji_decoder_1.FUJI_MAGIC_STRING.charCodeAt(i)) | ||
return false; | ||
} | ||
return true; | ||
} | ||
function createDecoder(bufferOrDecoder) { | ||
@@ -27,2 +36,5 @@ if (isDecoder(bufferOrDecoder)) { | ||
} | ||
else if (isLikelyFuji(bufferOrDecoder)) { | ||
return new fuji_decoder_1.FujiDecoder(bufferOrDecoder); | ||
} | ||
else if (isLikelyTIFF(bufferOrDecoder)) { | ||
@@ -29,0 +41,0 @@ return new tiff_decoder_1.TIFFDecoder(bufferOrDecoder); |
@@ -14,2 +14,3 @@ import { IBufferLike, IReader, Endian } from '../utils/types'; | ||
private _readBE; | ||
readAsString(length: number): string; | ||
readAsBuffer(length: number): IBufferLike; | ||
@@ -16,0 +17,0 @@ readAsReader(length: number): IReader; |
@@ -41,2 +41,7 @@ "use strict"; | ||
} | ||
readAsString(length) { | ||
const value = this._buffer.slice(this._position, this._position + length); | ||
this._position += length; | ||
return value.toString(); | ||
} | ||
readAsBuffer(length) { | ||
@@ -43,0 +48,0 @@ const value = this._buffer.slice(this._position, this._position + length); |
@@ -19,2 +19,3 @@ /// <reference types="node" /> | ||
read(length: number): number; | ||
readAsString(length: number): string; | ||
readAsBuffer(length: number): IBufferLike; | ||
@@ -21,0 +22,0 @@ readAsReader(length: number): IReader; |
@@ -88,3 +88,3 @@ import {getFriendlyName} from '../utils/tags' | ||
log.verbose(`read tag ${tag}`, dataReader) | ||
log.verbose(`read tag ${getFriendlyName(tag)} (${tag})`) | ||
return new IFDEntry(startOffset, tag, dataType, length, dataReader) | ||
@@ -91,0 +91,0 @@ } |
@@ -23,2 +23,9 @@ import {IFD} from '../decoder/ifd' | ||
const TIFF_MAGIC_VERSION = 42 | ||
/** | ||
* Olympus raw files are basically TIFFs but with a replaced magic text | ||
* @see https://libopenraw.freedesktop.org/formats/orf/ | ||
*/ | ||
const OLYMPUS_MAGIC_VERSION = 0x4f52 | ||
const log = createLogger('decoder') | ||
@@ -54,8 +61,8 @@ | ||
} else { | ||
throw new Error('Unrecognized format') | ||
throw new Error('Unrecognized TIFF format') | ||
} | ||
const version = this._reader.read(2) | ||
if (version !== 42) { | ||
throw new Error(`Unrecognized format: ${version.toString(16)}`) | ||
if (version !== TIFF_MAGIC_VERSION && version !== OLYMPUS_MAGIC_VERSION) { | ||
throw new Error(`Unrecognized TIFF version: ${version.toString(16)}`) | ||
} | ||
@@ -62,0 +69,0 @@ } |
import {JPEGDecoder} from './decoder/jpeg-decoder' | ||
import {FUJI_MAGIC_STRING, FujiDecoder} from './decoder/fuji-decoder' | ||
import {TIFFDecoder} from './decoder/tiff-decoder' | ||
@@ -17,5 +18,15 @@ import {XMPDecoder} from './decoder/xmp-decoder' | ||
function isLikelyFuji(buffer: IBufferLike): boolean { | ||
for (let i = 0; i < FUJI_MAGIC_STRING.length; i++) { | ||
if (buffer[i] !== FUJI_MAGIC_STRING.charCodeAt(i)) return false | ||
} | ||
return true | ||
} | ||
export function createDecoder(bufferOrDecoder: IBufferLike | IDecoder): IDecoder { | ||
if (isDecoder(bufferOrDecoder)) { | ||
return bufferOrDecoder | ||
} else if (isLikelyFuji(bufferOrDecoder)) { | ||
return new FujiDecoder(bufferOrDecoder) | ||
} else if (isLikelyTIFF(bufferOrDecoder)) { | ||
@@ -36,4 +47,12 @@ return new TIFFDecoder(bufferOrDecoder) | ||
export {normalizeMetadata, TIFFDecoder, JPEGDecoder, XMPDecoder, TIFFEncoder, XMPEncoder} | ||
export { | ||
normalizeMetadata, | ||
TIFFDecoder, | ||
FujiDecoder, | ||
JPEGDecoder, | ||
XMPDecoder, | ||
TIFFEncoder, | ||
XMPEncoder, | ||
} | ||
export {IGenericMetadata, INormalizedMetadata, IParsedLens, IFDTagName} from './utils/types' |
@@ -48,2 +48,8 @@ import {IBufferLike, IReader, Endian} from '../utils/types' | ||
public readAsString(length: number): string { | ||
const value = this._buffer.slice(this._position, this._position + length) | ||
this._position += length | ||
return value.toString() | ||
} | ||
public readAsBuffer(length: number): IBufferLike { | ||
@@ -50,0 +56,0 @@ const value = this._buffer.slice(this._position, this._position + length) |
@@ -22,2 +22,3 @@ export interface ILogger { | ||
read(length: number): number | ||
readAsString(length: number): string | ||
readAsBuffer(length: number): IBufferLike | ||
@@ -24,0 +25,0 @@ readAsReader(length: number): IReader |
{ | ||
"name": "@eris/exif", | ||
"version": "0.4.2-alpha.9", | ||
"version": "0.4.2-alpha.10", | ||
"description": "Parses EXIF data.", | ||
@@ -40,3 +40,3 @@ "main": "./dist/index.js", | ||
}, | ||
"gitHead": "2c615f75d1f04dcbc7971c632782fe4d20fc680a" | ||
"gitHead": "5c0400259b4be16eb1deeffc855d3ba62874a626" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
239518
77
4410