mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Ensure autoOrient occurs before non-90 rotation #4425
- Separate orient vs rotate ordering logic - Simplify EXIF auto-orient by using only rotate and/or flop
This commit is contained in:
@@ -565,9 +565,9 @@ describe('Rotation', function () {
|
||||
.raw()
|
||||
.toBuffer();
|
||||
|
||||
assert.strictEqual(r, 60);
|
||||
assert.strictEqual(g, 73);
|
||||
assert.strictEqual(b, 52);
|
||||
assert.strictEqual(r, 61);
|
||||
assert.strictEqual(g, 74);
|
||||
assert.strictEqual(b, 51);
|
||||
});
|
||||
|
||||
it('Flip and rotate ordering', async () => {
|
||||
@@ -648,6 +648,27 @@ describe('Rotation', function () {
|
||||
assert.strictEqual(orientation, undefined);
|
||||
});
|
||||
|
||||
it('Auto-orient and rotate 45', async () => {
|
||||
const data = await sharp(fixtures.inputJpgWithLandscapeExif2, { autoOrient: true })
|
||||
.rotate(45)
|
||||
.toBuffer();
|
||||
|
||||
const { width, height } = await sharp(data).metadata();
|
||||
assert.strictEqual(width, 742);
|
||||
assert.strictEqual(height, 742);
|
||||
});
|
||||
|
||||
it('Auto-orient, extract and rotate 45', async () => {
|
||||
const data = await sharp(fixtures.inputJpgWithLandscapeExif2, { autoOrient: true })
|
||||
.extract({ left: 20, top: 20, width: 200, height: 100 })
|
||||
.rotate(45)
|
||||
.toBuffer();
|
||||
|
||||
const { width, height } = await sharp(data).metadata();
|
||||
assert.strictEqual(width, 212);
|
||||
assert.strictEqual(height, 212);
|
||||
});
|
||||
|
||||
it('Invalid autoOrient throws', () =>
|
||||
assert.throws(
|
||||
() => sharp({ autoOrient: 'fail' }),
|
||||
|
||||
Reference in New Issue
Block a user