Socket
Socket
Sign inDemoInstall

image-size

Package Overview
Dependencies
0
Maintainers
3
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.1 to 0.5.2

1

lib/index.js

@@ -42,2 +42,3 @@ 'use strict';

var size = fs.fstatSync(descriptor).size;
if (size <= 0){return callback(new Error("File size is not greater than 0 —— " + filepath)); }
var bufferSize = Math.min(size, MaxBufferSize);

@@ -44,0 +45,0 @@ var buffer = new Buffer(bufferSize);

8

lib/types/jpg.js

@@ -10,3 +10,2 @@ 'use strict';

var SOIMarker = buffer.toString('hex', 0, 2);
return ('ffd8' === SOIMarker);

@@ -35,3 +34,3 @@ }

// Skip 5 chars, they are for signature
// Skip 4 chars, they are for signature
buffer = buffer.slice(4);

@@ -47,6 +46,7 @@

// 0xFFC0 is baseline(SOF)
// 0xFFC0 is baseline standard(SOF)
// 0xFFC1 is baseline optimized(SOF)
// 0xFFC2 is progressive(SOF2)
next = buffer[i + 1];
if (next === 0xC0 || next === 0xC2) {
if (next === 0xC0 || next === 0xC1 || next === 0xC2) {
return extractSize(buffer, i + 5);

@@ -53,0 +53,0 @@ }

'use strict';
var pngSignature = 'PNG\r\n\x1a\n';
var pngImageHeaderChunkName = 'IHDR';
var pngFriedChunkName = 'CgBI'; // Used to detect "fried" png's: http://www.jongware.com/pngdefry.html
function isPNG (buffer) {
if (pngSignature === buffer.toString('ascii', 1, 8)) {
if ('IHDR' !== buffer.toString('ascii', 12, 16)) {
var chunkName = buffer.toString('ascii', 12, 16);
if (chunkName === pngFriedChunkName) {
chunkName = buffer.toString('ascii', 28, 32);
}
if (chunkName !== pngImageHeaderChunkName) {
throw new TypeError('invalid png');

@@ -14,2 +21,8 @@ }

function calculate (buffer) {
if (buffer.toString('ascii', 12, 16) === pngFriedChunkName) {
return {
'width': buffer.readUInt32BE(32),
'height': buffer.readUInt32BE(36)
};
}
return {

@@ -16,0 +29,0 @@ 'width': buffer.readUInt32BE(16),

{
"name": "image-size",
"version": "0.5.1",
"version": "0.5.2",
"description": "get dimensions of any image file",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc