
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
graphicsmagick-stream
Advanced tools
Fast convertion/scaling of images using a pool of long lived graphicsmagick processes
Fast convertion/scaling of images using a pool of long lived graphicsmagick processes
npm install graphicsmagick-stream
It works by spawning and reusing a custom graphicsmagick processes (see src/) that accepts images over stdin and pipes out the converted result over stdout
var gm = require('graphicsmagick-stream')
var fs = require('fs')
var convert = gm({
pool: 5, // how many graphicsmagick processes to use
format: 'png', // format to convert to
scale: {
width: 200, // scale input to this width
height: 200, // scale input this height
ratio: true, // keep the aspect ratio (defaults to true)
type: 'contain' // scale type (either contain/cover)
},
crop: {
width: 200, // crop input to this width
height: 200, // crop input this height
x: 0, // crop using this x offset
y: 0 // crop using this y offset
},
rotate: 'auto', // auto rotate image based on exif data
// or use rotate:degrees
density: 300 // set the image density. useful when converting pdf to images
})
fs.createReadStream('input.jpg')
.pipe(convert({
// override any of the above options here
}))
.pipe(fs.createWriteStream('output.jpg'))
You do not need to set all the options. If you only want to scale an image do
var stream = convert({
scale: {
width: 400,
height: 300
}
})
You can also use it to get metadata info about an image using convert.info
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
If you install ghostscript as well you'll be able to convert pdfs to images
by simply piping in a pdf and setting output format to jpeg
(or another image format)
You need to install libgraphicsmagicks in order to compile this.
brew install graphicsmagick --build-from-source
sudo apt-get install libgraphicsmagick1-dev
MIT
FAQs
Fast convertion/scaling of images using a pool of long lived graphicsmagick processes
The npm package graphicsmagick-stream receives a total of 3 weekly downloads. As such, graphicsmagick-stream popularity was classified as not popular.
We found that graphicsmagick-stream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.