Add trim operation to remove "boring" edges (#491 #492)

This commit is contained in:
Kleis Auke Wolthuizen
2016-07-08 23:19:10 +02:00
committed by Lovell Fuller
parent 673d8278b5
commit b69627891d
9 changed files with 136 additions and 6 deletions

View File

@@ -56,6 +56,7 @@ using sharp::EntropyCrop;
using sharp::TileCache;
using sharp::Threshold;
using sharp::Bandbool;
using sharp::Trim;
using sharp::ImageType;
using sharp::ImageTypeId;
@@ -207,6 +208,11 @@ class PipelineWorker : public AsyncWorker {
RemoveExifOrientation(image);
}
// Trim
if(baton->trimTolerance != 0) {
image = Trim(image, baton->trimTolerance);
}
// Pre extraction
if (baton->topOffsetPre != -1) {
image = image.extract_area(baton->leftOffsetPre, baton->topOffsetPre, baton->widthPre, baton->heightPre);
@@ -1145,6 +1151,10 @@ NAN_METHOD(pipeline) {
baton->sharpenJagged = attrAs<double>(options, "sharpenJagged");
baton->threshold = attrAs<int32_t>(options, "threshold");
baton->thresholdGrayscale = attrAs<bool>(options, "thresholdGrayscale");
baton->trimTolerance = attrAs<int32_t>(options, "trimTolerance");
if(baton->accessMethod == VIPS_ACCESS_SEQUENTIAL && baton->trimTolerance != 0) {
baton->accessMethod = VIPS_ACCESS_RANDOM;
}
baton->gamma = attrAs<double>(options, "gamma");
baton->greyscale = attrAs<bool>(options, "greyscale");
baton->normalize = attrAs<bool>(options, "normalize");