Comparing version 1.1.0 to 1.2.0
@@ -6,3 +6,4 @@ 'use strict'; | ||
'png': require('./types/png'), | ||
'jpeg': require('./types/jpeg') | ||
'jpeg': require('./types/jpeg'), | ||
'gif': require('./types/gif') | ||
}; |
@@ -5,3 +5,2 @@ 'use strict'; | ||
var Promise = require('bluebird'); | ||
var pfstat = Promise.promisify(fs.fstat); | ||
var pread = Promise.promisify(fs.read); | ||
@@ -11,4 +10,3 @@ var utils = require('../utils'); | ||
function isPNG (buffer) { | ||
return 'PNG\r\n\x1a\n' === utils.ascii(buffer, 1, 8) && | ||
'IHDR' === utils.ascii(buffer, 12, 16); | ||
return 'PNG\r\n\x1a\n' === utils.ascii(buffer, 1, 8) && 'IHDR' === utils.ascii(buffer, 12, 16); | ||
} | ||
@@ -15,0 +13,0 @@ |
{ | ||
"name": "calipers", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "The fastest Node.js library for measuring PDF, PNG, and JPEG dimensions.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -1,6 +0,6 @@ | ||
# calipers [![npm version](https://badge.fury.io/js/calipers.svg)](http://badge.fury.io/js/calipers) [![Build Status](https://travis-ci.org/lob/calipers.svg)](https://travis-ci.org/lob/calipers) [![Coverage Status](https://coveralls.io/repos/lob/calipers/badge.svg)](https://coveralls.io/r/lob/calipers) | ||
<img src="https://s3-us-west-2.amazonaws.com/devassets.lob.com/calipers.jpg" width="700"> | ||
The fastest Node.js library for measuring **PDF**, **PNG**, and **JPEG** dimensions. | ||
[![npm version](https://badge.fury.io/js/calipers.svg)](http://badge.fury.io/js/calipers) [![Build Status](https://travis-ci.org/lob/calipers.svg)](https://travis-ci.org/lob/calipers) [![Coverage Status](https://coveralls.io/repos/lob/calipers/badge.svg)](https://coveralls.io/r/lob/calipers) | ||
Calipers was built to provide method of determining the dimensions of an image or PDF much faster and less resource-intensive than shelling-out to ImageMagick. At [Lob](https://lob.com) we must validate image and PDF sizes during request-time. The simplest way to do this is to shell-out to ImageMagick to identify the type and size of a file. For high-traffic servers, this becomes a major bottleneck due to the innefficiency of shelling-out. | ||
Calipers was built to provide a method of determining the dimensions of an image or PDF much faster and less resource-intensive than shelling-out to ImageMagick. At [Lob](https://lob.com) we must validate image and PDF sizes during the lifecyle of an API request. The simplest way to do this is to shell-out to ImageMagick to identify the type and size of a file. For high-traffic servers, this becomes a major bottleneck due to the innefficiency of shelling-out. | ||
@@ -13,7 +13,7 @@ Calipers remains performant because it avoids spawning child processes and it doesn't read entire files into memory. Instead, it intelligently reads only parts of the files that are necessary to determine the type and the dimensions of the file. | ||
Measures the PDF, PNG, or JPEG file at the given path. | ||
Measures the PDF, PNG, GIF, or JPEG file at the given path. | ||
- `filePath` - The path of the file. | ||
- `callback` - called when the file has been measured | ||
- `err` - An Error is thrown for unsupported file types or corrupt files. | ||
- `result` - Contains keys `type` and `pages`, where `type` is one of `'png'`, `'pdf'`, or `'jpeg'`, and `pages` is an array of objects with keys `width` and `height`. For PNG and JPEG files, `pages` always has 1 element and `width` and `height` are the integer pixel dimensions. For PDF `width` and `height` are floating-point PostScript Point dimensions. | ||
- `result` - Contains keys `type` and `pages`, where `type` is one of `'png'`, `'pdf'`, `'gif'`, or `'jpeg'`, and `pages` is an array of objects with keys `width` and `height`. For PNG and JPEG files, `pages` always has 1 element and `width` and `height` are the integer pixel dimensions. For PDF `width` and `height` are floating-point PostScript Point dimensions. | ||
@@ -26,3 +26,3 @@ # Examples | ||
// You can use a callback: | ||
calipers.measure('/path/to/image.png', function (err, result) { | ||
calipers.measure('/path/to/document.pdf', function (err, result) { | ||
// result: | ||
@@ -29,0 +29,0 @@ // { |
Sorry, the diff of this file is not supported yet
7598114
59
493
11