Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
crop-image-stream
Advanced tools
Crop an image stream
Crops a raw image stream, returns a cropped raw image stream, compatible with pixel-stream
. Everything is streams, so you can crop giant images without a memory overhead, only one line of the input image is held in memory at a time.
npm i --save crop-image-stream
See examples.
var fs = require('fs')
var path = require('path')
var JPEGDecoder = require('jpg-stream/decoder')
var JPEGEncoder = require('jpg-stream/encoder')
var Crop = require('crop-image-stream')
var inputFilename = path.join(__dirname, 'dramatic_chipmunk.jpg')
var outputFilename = path.join(__dirname, 'dramatic_chipmunk_crop.jpg')
var cropOpts = {
x: 575,
y: 20,
width: 275,
height: 200
}
fs.createReadStream(inputFilename)
.pipe(new JPEGDecoder())
.pipe(Crop(cropOpts))
.pipe(new JPEGEncoder())
.pipe(fs.createWriteStream(outputFilename))
var Crop = require('crop-image-stream')
Where:
opts.x
- X coordinate of left side of crop area, measured from the left of the original image. Default 0
opts.y
- Y coordinate of top of crop area, measured from the top of the original image. Default 0
opts.width
- Width of crop area. Default input image width. If opts.x + opts.width > inputImageWidth
, the crop area width will be inputImageWidth - opts.x
opts.height
- Height of crop area. Default input image height. If opts.y + opts.height > inputImageHeight
, the crop area height will be inputImageHeight - opts.y
You must pipe a stream of raw image data that emits a format
event with format = {height: inputImageHeight, width: inputImageWidth, colorSpace: inputImageColorSpace
. Returns a stream of raw image data which will also emit a format
event. Compatible with pixel-stream
but does not support frames (animated images).
PRs accepted.
Small note: If editing the Readme, please conform to the standard-readme specification.
MIT © Digital Democracy
FAQs
Crop an image stream
The npm package crop-image-stream receives a total of 0 weekly downloads. As such, crop-image-stream popularity was classified as not popular.
We found that crop-image-stream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.