image-size
Advanced tools
Comparing version 0.8.2 to 0.8.3
/// <reference types="node" /> | ||
import { ISizes, ISize } from './types/interface'; | ||
import { ISizeCalculationResult } from './types/interface'; | ||
import './fs.promises'; | ||
declare type CallbackFn = (e: Error | null, b?: Buffer) => void; | ||
declare type Dimensions = ISize | ISizes | null | undefined; | ||
export declare function imageSize(input: Buffer | string): Dimensions; | ||
declare type CallbackFn = (e: Error | null, r?: ISizeCalculationResult) => void; | ||
export declare function imageSize(input: Buffer | string): ISizeCalculationResult; | ||
export declare function imageSize(input: string, callback: CallbackFn): void; | ||
@@ -8,0 +7,0 @@ export declare const setConcurrency: (c: number) => void; |
@@ -9,2 +9,4 @@ "use strict"; | ||
const ico_1 = require("./types/ico"); | ||
const j2c_1 = require("./types/j2c"); | ||
const jp2_1 = require("./types/jp2"); | ||
const jpg_1 = require("./types/jpg"); | ||
@@ -25,2 +27,4 @@ const ktx_1 = require("./types/ktx"); | ||
ico: ico_1.ICO, | ||
j2c: j2c_1.J2C, | ||
jp2: jp2_1.JP2, | ||
jpg: jpg_1.JPG, | ||
@@ -27,0 +31,0 @@ ktx: ktx_1.KTX, |
@@ -55,12 +55,13 @@ "use strict"; | ||
} | ||
const imgs = [imageSize]; | ||
for (let imageIndex = 1; imageIndex < nbImages; imageIndex += 1) { | ||
imgs.push(getImageSize(buffer, imageIndex)); | ||
} | ||
const result = { | ||
height: imageSize.height, | ||
images: [imageSize], | ||
images: imgs, | ||
width: imageSize.width | ||
}; | ||
for (let imageIndex = 1; imageIndex < nbImages; imageIndex += 1) { | ||
result.images.push(getImageSize(buffer, imageIndex)); | ||
} | ||
return result; | ||
} | ||
}; |
@@ -5,12 +5,11 @@ /// <reference types="node" /> | ||
height: number | undefined; | ||
orientation?: number | undefined; | ||
orientation?: number; | ||
type?: string; | ||
} | ||
export interface ISizes { | ||
result: ISize[]; | ||
type?: string; | ||
export interface ISizeCalculationResult extends ISize { | ||
images?: ISize[]; | ||
} | ||
export interface IImage { | ||
validate: (buffer: Buffer) => boolean; | ||
calculate: (buffer: Buffer, filepath?: string) => ISize | ISizes | undefined; | ||
calculate: (buffer: Buffer, filepath?: string) => ISizeCalculationResult; | ||
} |
@@ -50,7 +50,3 @@ "use strict"; | ||
} | ||
function calculateByViewbox(attrs) { | ||
const viewbox = attrs && attrs.viewbox; | ||
if (!viewbox) { | ||
return; | ||
} | ||
function calculateByViewbox(attrs, viewbox) { | ||
const ratio = viewbox.width / viewbox.height; | ||
@@ -87,3 +83,3 @@ if (attrs.width) { | ||
if (attrs.viewbox) { | ||
return calculateByViewbox(attrs); | ||
return calculateByViewbox(attrs, attrs.viewbox); | ||
} | ||
@@ -90,0 +86,0 @@ } |
{ | ||
"name": "image-size", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"description": "get dimensions of any image file", | ||
@@ -48,10 +48,10 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/node": "12.7.5", | ||
"@types/node": "12.7.8", | ||
"chai": "4.2.0", | ||
"coveralls": "3.0.6", | ||
"eslint": "6.4.0", | ||
"eslint": "6.5.0", | ||
"glob": "7.1.4", | ||
"mocha": "6.2.0", | ||
"mocha": "6.2.1", | ||
"nyc": "14.1.1", | ||
"sinon": "7.4.2", | ||
"sinon": "7.5.0", | ||
"tslint": "5.20.0", | ||
@@ -58,0 +58,0 @@ "typescript": "3.6.3" |
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
43706
48
1144