fix: 画像ファイルの縦横サイズの取得で Exif Orientation を考慮する (#8014)

* 画像ファイルの縦横サイズの取得で Exif Orientation を考慮する

* test: Add rotate.jpg test

* Webpublic 画像を返す時のみ Exif Orientation を考慮して縦横サイズを返す

* test: Support orientation
This commit is contained in:
xianon 2021-12-03 11:19:28 +09:00 committed by GitHub
parent f33ded3107
commit 22464c434e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 70 additions and 8 deletions

View file

@ -17,6 +17,7 @@ describe('Get file info', () => {
},
width: undefined,
height: undefined,
orientation: undefined,
});
}));
@ -34,6 +35,7 @@ describe('Get file info', () => {
},
width: 512,
height: 512,
orientation: undefined,
});
}));
@ -51,6 +53,7 @@ describe('Get file info', () => {
},
width: 256,
height: 256,
orientation: undefined,
});
}));
@ -68,6 +71,7 @@ describe('Get file info', () => {
},
width: 256,
height: 256,
orientation: undefined,
});
}));
@ -85,6 +89,7 @@ describe('Get file info', () => {
},
width: 256,
height: 256,
orientation: undefined,
});
}));
@ -102,6 +107,7 @@ describe('Get file info', () => {
},
width: 256,
height: 256,
orientation: undefined,
});
}));
@ -120,6 +126,7 @@ describe('Get file info', () => {
},
width: 256,
height: 256,
orientation: undefined,
});
}));
@ -137,6 +144,25 @@ describe('Get file info', () => {
},
width: 25000,
height: 25000,
orientation: undefined,
});
}));
it('Rotate JPEG', async (async () => {
const path = `${__dirname}/resources/rotate.jpg`;
const info = await getFileInfo(path) as any;
delete info.warnings;
delete info.blurhash;
assert.deepStrictEqual(info, {
size: 12624,
md5: '68d5b2d8d1d1acbbce99203e3ec3857e',
type: {
mime: 'image/jpeg',
ext: 'jpg'
},
width: 512,
height: 256,
orientation: 8,
});
}));
});