mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Prevent auto-rotate fail for libmagick formats #117
This commit is contained in:
parent
f7c2a839ad
commit
740838b47c
@ -657,7 +657,10 @@ class ResizeWorker : public NanAsyncWorker {
|
|||||||
bool flip = FALSE;
|
bool flip = FALSE;
|
||||||
if (angle == -1) {
|
if (angle == -1) {
|
||||||
const char *exif;
|
const char *exif;
|
||||||
if (!vips_image_get_string(input, "exif-ifd0-Orientation", &exif)) {
|
if (
|
||||||
|
vips_image_get_typeof(input, "exif-ifd0-Orientation") != 0 &&
|
||||||
|
!vips_image_get_string(input, "exif-ifd0-Orientation", &exif)
|
||||||
|
) {
|
||||||
if (exif[0] == 0x36) { // "6"
|
if (exif[0] == 0x36) { // "6"
|
||||||
rotate = ANGLE_90;
|
rotate = ANGLE_90;
|
||||||
} else if (exif[0] == 0x33) { // "3"
|
} else if (exif[0] == 0x33) { // "3"
|
||||||
|
@ -68,6 +68,21 @@ describe('Rotation', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Attempt to auto-rotate image format without EXIF support', function(done) {
|
||||||
|
sharp(fixtures.inputGif)
|
||||||
|
.rotate()
|
||||||
|
.resize(320)
|
||||||
|
.jpeg()
|
||||||
|
.toBuffer(function(err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual(true, data.length > 0);
|
||||||
|
assert.strictEqual('jpeg', info.format);
|
||||||
|
assert.strictEqual(320, info.width);
|
||||||
|
assert.strictEqual(213, info.height);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Rotate to an invalid angle, should fail', function(done) {
|
it('Rotate to an invalid angle, should fail', function(done) {
|
||||||
var fail = false;
|
var fail = false;
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user