mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Auto-width and height calcs now round instead of floor
I think this will better match people's expectations
This commit is contained in:
parent
321e0f2bfe
commit
b8885c1faa
@ -317,7 +317,7 @@ class PipelineWorker : public NanAsyncWorker {
|
|||||||
} else {
|
} else {
|
||||||
// Auto height
|
// Auto height
|
||||||
yfactor = xfactor;
|
yfactor = xfactor;
|
||||||
baton->height = static_cast<int>(floor(static_cast<double>(inputHeight) / yfactor));
|
baton->height = static_cast<int>(round(static_cast<double>(inputHeight) / yfactor));
|
||||||
}
|
}
|
||||||
} else if (baton->height > 0) {
|
} else if (baton->height > 0) {
|
||||||
// Fixed height
|
// Fixed height
|
||||||
@ -327,7 +327,7 @@ class PipelineWorker : public NanAsyncWorker {
|
|||||||
} else {
|
} else {
|
||||||
// Auto width
|
// Auto width
|
||||||
xfactor = yfactor;
|
xfactor = yfactor;
|
||||||
baton->width = static_cast<int>(floor(static_cast<double>(inputWidth) / xfactor));
|
baton->width = static_cast<int>(round(static_cast<double>(inputWidth) / xfactor));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Identity transform
|
// Identity transform
|
||||||
|
@ -36,7 +36,7 @@ describe('Resize dimensions', function() {
|
|||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
assert.strictEqual(true, data.length > 0);
|
assert.strictEqual(true, data.length > 0);
|
||||||
assert.strictEqual('jpeg', info.format);
|
assert.strictEqual('jpeg', info.format);
|
||||||
assert.strictEqual(391, info.width);
|
assert.strictEqual(392, info.width);
|
||||||
assert.strictEqual(320, info.height);
|
assert.strictEqual(320, info.height);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -59,7 +59,7 @@ describe('Resize dimensions', function() {
|
|||||||
assert.strictEqual(true, data.length > 0);
|
assert.strictEqual(true, data.length > 0);
|
||||||
assert.strictEqual('jpeg', info.format);
|
assert.strictEqual('jpeg', info.format);
|
||||||
assert.strictEqual(3000, info.width);
|
assert.strictEqual(3000, info.width);
|
||||||
assert.strictEqual(2449, info.height);
|
assert.strictEqual(2450, info.height);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -28,7 +28,7 @@ describe('Rotation', function() {
|
|||||||
assert.strictEqual(true, data.length > 0);
|
assert.strictEqual(true, data.length > 0);
|
||||||
assert.strictEqual('jpeg', info.format);
|
assert.strictEqual('jpeg', info.format);
|
||||||
assert.strictEqual(320, info.width);
|
assert.strictEqual(320, info.width);
|
||||||
assert.strictEqual(426, info.height);
|
assert.strictEqual(427, info.height);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user