-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add joinChannel and toColourspace commands #513
Changes from 11 commits
539f7f3
70a6985
8f5da58
6d1d1b3
68d6fa2
b85de24
1b33fbf
bb18328
856c7d1
c9849cf
b38bc03
816204b
6f79a99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,7 @@ var Sharp = function(input, options) { | |
normalize: 0, | ||
booleanBufferIn: null, | ||
booleanFileIn: '', | ||
joinChannelIn: [], | ||
// overlay | ||
overlayGravity: 0, | ||
overlayXOffset : -1, | ||
|
@@ -109,6 +110,7 @@ var Sharp = function(input, options) { | |
tileSize: 256, | ||
tileOverlap: 0, | ||
extractChannel: -1, | ||
colourspace: 'srgb', | ||
// Function to notify of queue length changes | ||
queueListener: function(queueLength) { | ||
module.exports.queue.emit('change', queueLength); | ||
|
@@ -421,6 +423,20 @@ Sharp.prototype.overlayWith = function(overlay, options) { | |
return this; | ||
}; | ||
|
||
/* | ||
Add another color channel to the image | ||
*/ | ||
Sharp.prototype.joinChannel = function(images, options) { | ||
if (Array.isArray(images)) { | ||
images.forEach(function(image, index) { | ||
this.options.joinChannelIn[index] = this._createInputDescriptor(image, options); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Woops. I'll make that change. |
||
}, this); | ||
} else { | ||
this.options.joinChannelIn.push(this._createInputDescriptor(images, options)); | ||
} | ||
return this; | ||
}; | ||
|
||
/* | ||
Rotate output image by 0, 90, 180 or 270 degrees | ||
Auto-rotation based on the EXIF Orientation tag is represented by an angle of -1 | ||
|
@@ -629,6 +645,18 @@ Sharp.prototype.greyscale = function(greyscale) { | |
}; | ||
Sharp.prototype.grayscale = Sharp.prototype.greyscale; | ||
|
||
/* | ||
Set output colourspace | ||
*/ | ||
Sharp.prototype.toColourspace = function(colourspace) { | ||
if (!isString(colourspace) ) { | ||
throw new Error('Invalid output colourspace ' + colourspace); | ||
} | ||
this.options.colourspace = colourspace; | ||
return this; | ||
}; | ||
Sharp.prototype.toColorspace = Sharp.prototype.toColourspace; | ||
|
||
Sharp.prototype.progressive = function(progressive) { | ||
this.options.progressive = isBoolean(progressive) ? progressive : true; | ||
return this; | ||
|
@@ -817,6 +845,15 @@ module.exports.bool = { | |
or: 'or', | ||
eor: 'eor' | ||
}; | ||
// Colourspaces | ||
module.exports.colourspace = { | ||
multiband: 'multiband', | ||
'b-w': 'b-w', | ||
bw: 'b-w', | ||
cmyk: 'cmyk', | ||
srgb: 'srgb' | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docs suggest other colourspaces are available, e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The trouble with other colorspaces supported by vips is that its hard to write images in those formats. You can always use the string nick to access them, but by not putting them in the |
||
module.exports.colorspace = module.exports.colourspace; | ||
|
||
/* | ||
Resize image to width x height pixels | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to include information that the images to be joined must be the same dimension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They actually don't have to be of the same dimension -- vips will expand the image to fit the largest channel.