mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-02 08:10:05 +00:00
Add types for exif
This commit is contained in:
18
types/exif/exif-tests.ts
Normal file
18
types/exif/exif-tests.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import Exif = require('exif');
|
||||
const ExifImage = Exif.ExifImage;
|
||||
|
||||
new ExifImage({ image: 'myImage.jpg' }, (error, exifData) => {
|
||||
if (error) {
|
||||
console.log(`Error: ${error.message}`);
|
||||
} else {
|
||||
console.log(exifData);
|
||||
}
|
||||
});
|
||||
|
||||
Exif('myImage.jpg', (error, exifData, dataPath) => {
|
||||
if (error) {
|
||||
console.log(`Error: ${error.message}`);
|
||||
} else {
|
||||
console.log(exifData, dataPath);
|
||||
}
|
||||
});
|
||||
143
types/exif/index.d.ts
vendored
Normal file
143
types/exif/index.d.ts
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
// Type definitions for exif 0.6
|
||||
// Project: https://github.com/gomfunkel/node-exif#readme
|
||||
// Definitions by: Florian Keller <https://github.com/ffflorian>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare namespace Exif {
|
||||
interface ExifData {
|
||||
image: {
|
||||
Copyright?: string;
|
||||
ExifOffset?: number;
|
||||
ImageHeight?: number;
|
||||
ImageWidth?: number;
|
||||
Make?: string;
|
||||
Model?: string;
|
||||
ModifyDate?: string;
|
||||
Orientation?: number;
|
||||
ResolutionUnit?: number;
|
||||
Software?: string;
|
||||
XResolution?: number;
|
||||
YCbCrPositioning?: number;
|
||||
YResolution?: number;
|
||||
};
|
||||
thumbnail: {
|
||||
Compression?: number;
|
||||
Orientation?: number;
|
||||
ResolutionUnit?: number;
|
||||
ThumbnailLength?: number;
|
||||
ThumbnailOffset?: number;
|
||||
XResolution?: number;
|
||||
YCbCrPositioning?: number;
|
||||
YResolution?: number;
|
||||
};
|
||||
exif: {
|
||||
ApertureValue?: number;
|
||||
BrightnessValue?: number;
|
||||
ColorSpace?: number;
|
||||
ComponentsConfiguration?: Buffer;
|
||||
CompressedBitsPerPixel?: number;
|
||||
CreateDate?: string;
|
||||
DateTimeOriginal?: string;
|
||||
ExifImageHeight?: number;
|
||||
ExifImageWidth?: number;
|
||||
ExifVersion?: Buffer;
|
||||
ExposureCompensation?: number;
|
||||
ExposureMode?: number;
|
||||
ExposureProgram?: number;
|
||||
ExposureTime?: number;
|
||||
FileSource?: Buffer;
|
||||
Flash?: number;
|
||||
FlashpixVersion?: Buffer;
|
||||
FNumber?: number;
|
||||
FocalLength?: number;
|
||||
FocalLengthIn35mmFormat?: number;
|
||||
FocalPlaneResolutionUnit?: number;
|
||||
FocalPlaneXResolution?: number;
|
||||
FocalPlaneYResolution?: number;
|
||||
ImageUniqueID?: string;
|
||||
InteropOffset?: number;
|
||||
ISO?: number;
|
||||
MakerNote?: Buffer;
|
||||
MaxApertureValue?: number;
|
||||
MeteringMode?: number;
|
||||
SceneCaptureType?: number;
|
||||
SceneType?: Buffer;
|
||||
SensingMethod?: number;
|
||||
ShutterSpeedValue?: number;
|
||||
UserComment?: Buffer;
|
||||
WhiteBalance?: number;
|
||||
};
|
||||
gps: {
|
||||
GPSAltitude?: number;
|
||||
GPSAltitudeRef?: number;
|
||||
GPSDateStamp?: string;
|
||||
GPSLatitude?: number[];
|
||||
GPSLatitudeRef?: string;
|
||||
GPSLongitude?: number[];
|
||||
GPSLongitudeRef?: string;
|
||||
GPSTimeStamp?: number[];
|
||||
GPSVersionId?: number[];
|
||||
};
|
||||
interoperability: {
|
||||
InteropIndex?: string;
|
||||
InteropVersion?: Buffer;
|
||||
};
|
||||
makernote: {
|
||||
AutoBracketing?: number;
|
||||
BlurWarning?: number;
|
||||
ExposureWarning?: number;
|
||||
error?: string;
|
||||
FlashExposureComp?: number;
|
||||
FocusMode?: number;
|
||||
FocusWarning?: number;
|
||||
FujiFlashMode?: number;
|
||||
Macro?: number;
|
||||
Quality?: string;
|
||||
Sharpness?: number;
|
||||
SlowSync?: number;
|
||||
Version?: Buffer;
|
||||
WhiteBalance?: number;
|
||||
};
|
||||
}
|
||||
|
||||
interface ExifOptions {
|
||||
agfaMaxEntries?: number;
|
||||
epsonMaxEntries?: number;
|
||||
/** node-exif corrects the thumbnail offset in order to have an offset from the start of the buffer/file. */
|
||||
fixThumbnailOffset?: boolean;
|
||||
fujifilmMaxEntries?: number;
|
||||
ifd0MaxEntries?: number;
|
||||
ifd1MaxEntries?: number;
|
||||
/**
|
||||
* The image to get Exif data from can be either a filesystem path or a Buffer.
|
||||
*
|
||||
* If `image` is not specified, the developer must call `loadImage()` to parse the image.
|
||||
*/
|
||||
image?: string | Buffer;
|
||||
/** Specifies the maximum entries to be parsed */
|
||||
maxEntries?: number;
|
||||
maxGpsEntries?: number;
|
||||
maxInteroperabilityEntries?: number;
|
||||
noPadding?: boolean;
|
||||
olympusMaxEntries?: number;
|
||||
panasonicMaxEntries?: number;
|
||||
sanyoMaxEntries?: number;
|
||||
/** An object named "offsets" is added to exifData and contains lot of offsets needed to get thumbnail and other things. */
|
||||
tiffOffsets?: number;
|
||||
}
|
||||
|
||||
type ExifImageCallback = (error: Error | null, data: ExifData) => void;
|
||||
type ExifCallback = (error: Error | null, data: ExifData, dataPath: string) => void;
|
||||
|
||||
class ExifImage {
|
||||
constructor(options: ExifOptions | string | Buffer, callback: ExifImageCallback);
|
||||
constructor();
|
||||
loadImage(file: string | Buffer, callback: ExifImageCallback): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare function Exif(path: string, callback: Exif.ExifCallback): void;
|
||||
|
||||
export = Exif;
|
||||
23
types/exif/tsconfig.json
Normal file
23
types/exif/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"exif-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/exif/tslint.json
Normal file
1
types/exif/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user