Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

image-size

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-size - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

dist/types/tga.d.ts

39

dist/index.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -58,19 +49,17 @@ exports.types = exports.setConcurrency = exports.disableTypes = exports.disableFS = exports.imageSize = void 0;

*/
function asyncFileToBuffer(filepath) {
return __awaiter(this, void 0, void 0, function* () {
const handle = yield fs.promises.open(filepath, 'r');
try {
const { size } = yield handle.stat();
if (size <= 0) {
throw new Error('Empty file');
}
const bufferSize = Math.min(size, MaxBufferSize);
const buffer = Buffer.alloc(bufferSize);
yield handle.read(buffer, 0, bufferSize, 0);
return buffer;
async function asyncFileToBuffer(filepath) {
const handle = await fs.promises.open(filepath, 'r');
try {
const { size } = await handle.stat();
if (size <= 0) {
throw new Error('Empty file');
}
finally {
yield handle.close();
}
});
const bufferSize = Math.min(size, MaxBufferSize);
const buffer = Buffer.alloc(bufferSize);
await handle.read(buffer, 0, bufferSize, 0);
return buffer;
}
finally {
await handle.close();
}
}

@@ -77,0 +66,0 @@ /**

@@ -16,2 +16,3 @@ export declare const typeHandlers: {

svg: import("./types/interface").IImage;
tga: import("./types/interface").IImage;
tiff: import("./types/interface").IImage;

@@ -18,0 +19,0 @@ webp: import("./types/interface").IImage;

@@ -19,2 +19,3 @@ "use strict";

const svg_1 = require("./types/svg");
const tga_1 = require("./types/tga");
const tiff_1 = require("./types/tiff");

@@ -37,4 +38,5 @@ const webp_1 = require("./types/webp");

svg: svg_1.SVG,
tga: tga_1.TGA,
tiff: tiff_1.TIFF,
webp: webp_1.WEBP,
};

@@ -8,6 +8,9 @@ "use strict";

validate(buffer) {
if (buffer.readUInt16LE(0) !== 0) {
const reserved = buffer.readUInt16LE(0);
const imageCount = buffer.readUInt16LE(4);
if (reserved !== 0 || imageCount === 0) {
return false;
}
return buffer.readUInt16LE(2) === TYPE_CURSOR;
const imageType = buffer.readUInt16LE(2);
return imageType === TYPE_CURSOR;
},

@@ -14,0 +17,0 @@ calculate(buffer) {

@@ -45,6 +45,9 @@ "use strict";

validate(buffer) {
if (buffer.readUInt16LE(0) !== 0) {
const reserved = buffer.readUInt16LE(0);
const imageCount = buffer.readUInt16LE(4);
if (reserved !== 0 || imageCount === 0) {
return false;
}
return buffer.readUInt16LE(2) === TYPE_ICON;
const imageType = buffer.readUInt16LE(2);
return imageType === TYPE_ICON;
},

@@ -51,0 +54,0 @@ calculate(buffer) {

{
"name": "image-size",
"version": "1.0.1",
"version": "1.0.2",
"description": "get dimensions of any image file",

@@ -12,3 +12,3 @@ "main": "dist/index.js",

"engines": {
"node": ">=12.0.0"
"node": ">=14.0.0"
},

@@ -36,2 +36,3 @@ "bin": "bin/image-size.js",

"psd",
"tga",
"tiff",

@@ -48,18 +49,18 @@ "webp",

"devDependencies": {
"@types/chai": "4.3.0",
"@types/chai": "4.3.1",
"@types/glob": "7.2.0",
"@types/mocha": "9.0.0",
"@types/node": "17.0.8",
"@types/sinon": "10.0.6",
"@typescript-eslint/eslint-plugin": "5.9.1",
"@typescript-eslint/parser": "5.9.1",
"chai": "4.3.4",
"eslint": "8.6.0",
"glob": "7.2.0",
"mocha": "9.1.3",
"@types/mocha": "9.1.1",
"@types/node": "18.0.3",
"@types/sinon": "10.0.12",
"@typescript-eslint/eslint-plugin": "5.30.6",
"@typescript-eslint/parser": "5.30.6",
"chai": "4.3.6",
"eslint": "8.19.0",
"glob": "8.0.3",
"mocha": "10.0.0",
"nyc": "15.1.0",
"sinon": "12.0.1",
"ts-node": "10.4.0",
"typedoc": "0.22.10",
"typescript": "4.5.4"
"sinon": "14.0.0",
"ts-node": "10.8.2",
"typedoc": "0.23.7",
"typescript": "4.7.4"
},

@@ -69,3 +70,3 @@ "dependencies": {

},
"packageManager": "yarn@3.1.1"
"packageManager": "yarn@3.2.0"
}

@@ -17,2 +17,4 @@ # image-size

* ICO
* J2C
* JP2
* JPEG

@@ -24,2 +26,3 @@ * KTX

* SVG
* TGA
* TIFF

@@ -26,0 +29,0 @@ * WebP

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc