mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-04 07:52:51 +00:00
Merge pull request #31541 from Slessi/jpeg-autorotate
Types for jpeg-autorotate
This commit is contained in:
commit
aa91ccd564
31
types/jpeg-autorotate/index.d.ts
vendored
Normal file
31
types/jpeg-autorotate/index.d.ts
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Type definitions for jpeg-autorotate 4.0
|
||||
// Project: https://github.com/johansatge/jpeg-autorotate#readme
|
||||
// Definitions by: Slessi <https://github.com/Slessi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export enum errors {
|
||||
read_file = "read_file",
|
||||
read_exif = "read_exif",
|
||||
no_orientation = "no_orientation",
|
||||
unknown_orientation = "unknown_orientation",
|
||||
correct_orientation = "correct_orientation",
|
||||
rotate_file = "rotate_file",
|
||||
}
|
||||
|
||||
export interface CustomError extends Error {
|
||||
code: errors;
|
||||
}
|
||||
|
||||
export function rotate(
|
||||
path_or_buffer: string | Buffer,
|
||||
options?: { quality?: number },
|
||||
module_callback?: (
|
||||
error: CustomError | null,
|
||||
buffer: Buffer | null,
|
||||
orientation: number | null,
|
||||
dimensions: { height: number; width: number } | null,
|
||||
) => void,
|
||||
): void;
|
||||
23
types/jpeg-autorotate/jpeg-autorotate-tests.ts
Normal file
23
types/jpeg-autorotate/jpeg-autorotate-tests.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import * as jo from "jpeg-autorotate";
|
||||
|
||||
jo.rotate("img.jpg");
|
||||
jo.rotate(new Buffer(""));
|
||||
jo.rotate(new Buffer(""), { quality: 50 });
|
||||
jo.rotate("img.jpg", { quality: 100 }, (error, buffer, orientation, dimensions) => {
|
||||
if (error && error.code === jo.errors.correct_orientation) {
|
||||
console.log("The orientation of this image is already correct!");
|
||||
}
|
||||
|
||||
if (orientation) {
|
||||
console.log("Orientation was: " + orientation);
|
||||
}
|
||||
|
||||
if (dimensions) {
|
||||
console.log("Height after rotation: " + dimensions.height);
|
||||
console.log("Width after rotation: " + dimensions.width);
|
||||
}
|
||||
|
||||
if (buffer) {
|
||||
buffer.readInt8(0);
|
||||
}
|
||||
});
|
||||
23
types/jpeg-autorotate/tsconfig.json
Normal file
23
types/jpeg-autorotate/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",
|
||||
"jpeg-autorotate-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/jpeg-autorotate/tslint.json
Normal file
1
types/jpeg-autorotate/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user