@@ -15,8 +15,16 @@ describe("EXIF orientation", () => {
15
15
orientedImg . write (
16
16
getTestDir ( __dirname ) + `/Landscape-output-${ orientation } -PR.jpg`
17
17
) ;
18
- expect ( orientedImg . getWidth ( ) ) . toBe ( regularImg . getWidth ( ) ) ;
19
- expect ( orientedImg . getHeight ( ) ) . toBe ( regularImg . getHeight ( ) ) ;
18
+
19
+ if ( orientation > 4 ) {
20
+ // 5, 6, 7, 8 dimmensions are swapped
21
+ expect ( orientedImg . getWidth ( ) ) . toBe ( regularImg . getHeight ( ) ) ;
22
+ expect ( orientedImg . getHeight ( ) ) . toBe ( regularImg . getWidth ( ) ) ;
23
+ } else {
24
+ expect ( orientedImg . getWidth ( ) ) . toBe ( regularImg . getWidth ( ) ) ;
25
+ expect ( orientedImg . getHeight ( ) ) . toBe ( regularImg . getHeight ( ) ) ;
26
+ }
27
+
20
28
expect ( Jimp . distance ( regularImg , orientedImg ) ) . toBeLessThan ( 0.07 ) ;
21
29
22
30
expect ( getExifOrientation ( orientedImg ) ) . toBe (
@@ -27,14 +35,22 @@ describe("EXIF orientation", () => {
27
35
28
36
for ( let orientation = 1 ; orientation <= 8 ; orientation ++ ) {
29
37
it ( `is fixed when EXIF orientation is ${ orientation } ` , async ( ) => {
30
- const regularImg = await imageWithOrientation ( 1 ) ;
31
- const orientedImg = await imageWithOrientation ( orientation ) ;
38
+ const regularImg = await imageWithOrientation2 ( 1 ) ;
39
+ const orientedImg = await imageWithOrientation2 ( orientation ) ;
32
40
33
41
orientedImg . write (
34
42
getTestDir ( __dirname ) + `/Portrait-output-${ orientation } -PR.jpg`
35
43
) ;
36
- expect ( orientedImg . getWidth ( ) ) . toBe ( regularImg . getWidth ( ) ) ;
37
- expect ( orientedImg . getHeight ( ) ) . toBe ( regularImg . getHeight ( ) ) ;
44
+
45
+ if ( orientation > 4 ) {
46
+ // 5, 6, 7, 8 dimmensions are swapped
47
+ expect ( orientedImg . getWidth ( ) ) . toBe ( regularImg . getHeight ( ) ) ;
48
+ expect ( orientedImg . getHeight ( ) ) . toBe ( regularImg . getWidth ( ) ) ;
49
+ } else {
50
+ expect ( orientedImg . getWidth ( ) ) . toBe ( regularImg . getWidth ( ) ) ;
51
+ expect ( orientedImg . getHeight ( ) ) . toBe ( regularImg . getHeight ( ) ) ;
52
+ }
53
+
38
54
expect ( Jimp . distance ( regularImg , orientedImg ) ) . toBeLessThan ( 0.07 ) ;
39
55
40
56
expect ( getExifOrientation ( orientedImg ) ) . toBe (
0 commit comments