Skip to content

Commit

Permalink
fix: tileCentre default false
Browse files Browse the repository at this point in the history
  • Loading branch information
beig committed Oct 7, 2020
1 parent 0792540 commit 3e2da28
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions lib/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ const Sharp = function (input, options) {
tileAngle: 0,
tileSkipBlanks: -1,
tileBackground: [255, 255, 255, 255],
tileCentre: false,
linearA: 1,
linearB: 0,
// Function to notify of libvips warnings
Expand Down
6 changes: 1 addition & 5 deletions lib/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,11 +729,7 @@ function tile (options) {
}
// Center image in tile
if (is.defined(options.centre) || is.defined(options.center)) {
if (is.bool(options.centre) || is.bool(options.center)) {
this.options.centre = options.centre || options.center;
} else {
throw is.invalidParameterError('centre', 'boolean', options.centre);
}
this._setBooleanOption('tileCentre', options.centre || options.center);
}
}
// Format
Expand Down
7 changes: 2 additions & 5 deletions src/pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ class PipelineWorker : public Napi::AsyncWorker {
->set("suffix", const_cast<char*>(suffix.data()))
->set("angle", CalculateAngleRotation(baton->tileAngle))
->set("background", baton->tileBackground)
->set("centre", baton->centre)
->set("centre", baton->tileCentre)
->set("skip_blanks", baton->tileSkipBlanks);
// libvips chooses a default depth based on layout. Instead of replicating that logic here by
// not passing anything - libvips will handle choice
Expand Down Expand Up @@ -1404,10 +1404,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
baton->tileDepth = static_cast<VipsForeignDzDepth>(
vips_enum_from_nick(nullptr, VIPS_TYPE_FOREIGN_DZ_DEPTH,
sharp::AttrAsStr(options, "tileDepth").data()));

if (sharp::HasAttr(options, "centre")) {
baton->centre = sharp::AttrAsBool(options, "centre");
}
baton->tileCentre = sharp::AttrAsBool(options, "tileCentre");

// Force random access for certain operations
if (baton->input->access == VIPS_ACCESS_SEQUENTIAL) {
Expand Down
2 changes: 1 addition & 1 deletion src/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct PipelineBaton {
int cropOffsetLeft;
int cropOffsetTop;
bool premultiplied;
bool centre;
bool tileCentre;
std::string kernel;
bool fastShrinkOnLoad;
double tintA;
Expand Down

0 comments on commit 3e2da28

Please sign in to comment.