From b8885c1faa325aaf711e5ea3335f56462413781c Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Fri, 3 Jul 2015 15:21:28 +0100 Subject: [PATCH] Auto-width and height calcs now round instead of floor I think this will better match people's expectations --- src/pipeline.cc | 4 ++-- test/unit/resize.js | 4 ++-- test/unit/rotate.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pipeline.cc b/src/pipeline.cc index b313355e..f448e2e6 100755 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -317,7 +317,7 @@ class PipelineWorker : public NanAsyncWorker { } else { // Auto height yfactor = xfactor; - baton->height = static_cast(floor(static_cast(inputHeight) / yfactor)); + baton->height = static_cast(round(static_cast(inputHeight) / yfactor)); } } else if (baton->height > 0) { // Fixed height @@ -327,7 +327,7 @@ class PipelineWorker : public NanAsyncWorker { } else { // Auto width xfactor = yfactor; - baton->width = static_cast(floor(static_cast(inputWidth) / xfactor)); + baton->width = static_cast(round(static_cast(inputWidth) / xfactor)); } } else { // Identity transform diff --git a/test/unit/resize.js b/test/unit/resize.js index 6eac393a..7cfd6bae 100755 --- a/test/unit/resize.js +++ b/test/unit/resize.js @@ -36,7 +36,7 @@ describe('Resize dimensions', function() { if (err) throw err; assert.strictEqual(true, data.length > 0); assert.strictEqual('jpeg', info.format); - assert.strictEqual(391, info.width); + assert.strictEqual(392, info.width); assert.strictEqual(320, info.height); done(); }); @@ -59,7 +59,7 @@ describe('Resize dimensions', function() { assert.strictEqual(true, data.length > 0); assert.strictEqual('jpeg', info.format); assert.strictEqual(3000, info.width); - assert.strictEqual(2449, info.height); + assert.strictEqual(2450, info.height); done(); }); }); diff --git a/test/unit/rotate.js b/test/unit/rotate.js index d722b3c9..98c888fa 100755 --- a/test/unit/rotate.js +++ b/test/unit/rotate.js @@ -28,7 +28,7 @@ describe('Rotation', function() { assert.strictEqual(true, data.length > 0); assert.strictEqual('jpeg', info.format); assert.strictEqual(320, info.width); - assert.strictEqual(426, info.height); + assert.strictEqual(427, info.height); done(); }); });