New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphicsmagick-stream

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphicsmagick-stream - npm Package Compare versions

Comparing version

to
1.1.0

.travis.yml

45

index.js

@@ -9,2 +9,3 @@ var proc = require('child_process')

var EMPTY = new Buffer(0)
var FORMATS = ['noop', 'info', 'jpeg', 'gif', 'png', 'bmp']

@@ -15,7 +16,8 @@ var toFormatType = function(format) {

switch (format.toLowerCase()) {
case 'info': return 1
case 'jpeg':
case 'jpg': return 1
case 'gif': return 2
case 'png': return 3
case 'bmp': return 4
case 'jpg': return 2
case 'gif': return 3
case 'png': return 4
case 'bmp': return 5
}

@@ -25,2 +27,10 @@ return 0

var fromInfoStruct = function(data) {
var result = {}
result.width = data.readUInt32LE(0)
result.height = data.readUInt32LE(4)
result.format = FORMATS[data.readUInt32LE(8)]
return result
}
var toUInt32LE = function(len) {

@@ -206,8 +216,29 @@ var buf = new Buffer(4)

if (!defaults) defaults = {}
var size = defaults.pool || 1
var convert = pool({size:size})
var exec = pool({size:size})
return function(opts) {
return convert(xtend(defaults, opts))
var convert = function(opts) {
return exec(xtend(defaults, opts))
}
convert.info = function(opts, cb) {
if (typeof opts === 'function') return convert.info(null, opts)
if (!opts) opts = {}
opts.format = 'info'
cb = once(cb)
var buf = []
return convert(opts)
.on('error', cb)
.on('data', function(data) {
buf.push(data)
})
.on('end', function() {
cb(null, fromInfoStruct(Buffer.concat(buf)))
})
}
return convert
}

8

package.json
{
"name": "graphicsmagick-stream",
"version": "1.0.0",
"version": "1.1.0",
"description": "Fast convertion/scaling of images using a pool of long lived graphicsmagick processes",

@@ -10,2 +10,5 @@ "main": "index.js",

},
"devDependencies": {
"tape": "^2.13.3"
},
"repository": {

@@ -25,3 +28,4 @@ "type": "git",

"scripts": {
"install": "make"
"install": "make",
"test": "tape test/*.js"
},

@@ -28,0 +32,0 @@ "author": "Mathias Buus",

@@ -9,2 +9,4 @@ # graphicsmagick-stream

[![Build Status](https://travis-ci.org/e-conomic/graphicsmagick-stream.png)](https://travis-ci.org/e-conomic/graphicsmagick-stream)
It works by spawning and reusing a custom graphicsmagick processes (see src/) that

@@ -45,2 +47,25 @@ accepts images over stdin and pipes out the converted result over stdout

You do not need to set all the options. If you only want to scale an image do
``` js
var stream = convert({
scale: {
width: 400,
height: 300
}
})
```
You can also use it to get metadata info about an image using `convert.info`
``` js
var info = convert.info(function(err, info) {
console.log(info) // prints something like {width:500, height:400, format:'png'}
})
fs.createReadStream('input.jpg').pipe(info)
```
For more examples and usage see the test folder
## Dependencies

@@ -57,2 +82,2 @@

MIT
MIT

Sorry, the diff of this file is not supported yet