mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add extractChannel operation to extract a channel from an image (#497)
This commit is contained in:
committed by
Lovell Fuller
parent
f672f86b53
commit
83d8847f57
@@ -789,6 +789,15 @@ class PipelineWorker : public AsyncWorker {
|
||||
image = Bandbool(image, baton->bandBoolOp);
|
||||
}
|
||||
|
||||
// Extract an image channel (aka vips band)
|
||||
if(baton->extractChannel > -1) {
|
||||
if(baton->extractChannel >= image.bands()) {
|
||||
(baton->err).append("Cannot extract channel from image. Too few channels in image.");
|
||||
return Error();
|
||||
}
|
||||
image = image.extract_band(baton->extractChannel);
|
||||
}
|
||||
|
||||
// Override EXIF Orientation tag
|
||||
if (baton->withMetadata && baton->withMetadataOrientation != -1) {
|
||||
SetExifOrientation(image, baton->withMetadataOrientation);
|
||||
@@ -1175,6 +1184,7 @@ NAN_METHOD(pipeline) {
|
||||
baton->extendBottom = attrAs<int32_t>(options, "extendBottom");
|
||||
baton->extendLeft = attrAs<int32_t>(options, "extendLeft");
|
||||
baton->extendRight = attrAs<int32_t>(options, "extendRight");
|
||||
baton->extractChannel = attrAs<int32_t>(options, "extractChannel");
|
||||
// Output options
|
||||
baton->progressive = attrAs<bool>(options, "progressive");
|
||||
baton->quality = attrAs<int32_t>(options, "quality");
|
||||
|
||||
@@ -94,6 +94,7 @@ struct PipelineBaton {
|
||||
double convKernelScale;
|
||||
double convKernelOffset;
|
||||
VipsOperationBoolean bandBoolOp;
|
||||
int extractChannel;
|
||||
int tileSize;
|
||||
int tileOverlap;
|
||||
VipsForeignDzContainer tileContainer;
|
||||
@@ -155,6 +156,7 @@ struct PipelineBaton {
|
||||
convKernelScale(0.0),
|
||||
convKernelOffset(0.0),
|
||||
bandBoolOp(VIPS_OPERATION_BOOLEAN_LAST),
|
||||
extractChannel(-1),
|
||||
tileSize(256),
|
||||
tileOverlap(0),
|
||||
tileContainer(VIPS_FOREIGN_DZ_CONTAINER_FS),
|
||||
|
||||
Reference in New Issue
Block a user