|
16 | 16 | 'use strict'
|
17 | 17 |
|
18 | 18 | var canCreateBlob = !!window.dataURLtoBlob
|
19 |
| - // 80x60px GIF image (color black, base64 data): |
| 19 | + // black 80x60 GIF: |
20 | 20 | var b64DataGIF =
|
21 | 21 | 'R0lGODdhUAA8AIABAAAAAP///ywAAAAAUAA8AAACS4SPqcvtD6' +
|
22 | 22 | 'OctNqLs968+w+G4kiW5omm6sq27gvH8kzX9o3n+s73/g8MCofE' +
|
23 | 23 | 'ovGITCqXzKbzCY1Kp9Sq9YrNarfcrvcLDovH5PKsAAA7'
|
24 | 24 | var imageUrlGIF = 'data:image/gif;base64,' + b64DataGIF
|
25 | 25 | var blobGIF = canCreateBlob && window.dataURLtoBlob(imageUrlGIF)
|
26 |
| - // black/white 1x2px JPEG, with the following meta information set: |
| 26 | + // black+white 3x2 JPEG, with the following meta information set: |
27 | 27 | // - EXIF Orientation: 6 (Rotated 90° CCW)
|
28 | 28 | // - IPTC ObjectName: blueimp.net
|
29 | 29 | // Meta information has been set via exiftool (exiftool.org):
|
30 | 30 | // exiftool -all= -Orientation#=6 -YCbCrPositioning= -ResolutionUnit= \
|
31 |
| - // -YResolution= -XResolution= -ObjectName=blueimp.net black+white-1x2.jpg |
| 31 | + // -YResolution= -XResolution= -ObjectName=blueimp.net black+white-3x2.jpg |
| 32 | + // Image data layout (B=black, F=white): |
| 33 | + // BFF |
| 34 | + // BBB |
32 | 35 | var b64DataJPEG =
|
33 | 36 | '/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/7QA0UGhvdG9zaG9wIDMu' +
|
34 |
| - 'MAA4QklNBAQAAAAAABccAgUAC2JsdWVpbXAubmV0HAIAAAIABAD/2wCEAAEBAQEBAQIBAQID' + |
35 |
| - 'AgICAwQDAwMDBAYEBAQEBAYHBgYGBgYGBwcHBwcHBwcICAgICAgJCQkJCQsLCwsLCwsLCwsB' + |
36 |
| - 'AgICAwMDBQMDBQsIBggLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsL' + |
37 |
| - 'CwsLCwsLCwsLC//AABEIAAIAAQMBIgACEQEDEQH/xABSAAEBAAAAAAAAAAAAAAAAAAAAChAB' + |
38 |
| - 'AAAHAAAAAAAAAAAAAAAAAAUHCRlYltQBAQAAAAAAAAAAAAAAAAAAAAARAQAAAAAAAAAAAAAA' + |
39 |
| - 'AAAAAAD/2gAMAwEAAhEDEQA/AK+bT1LLGmVWmwjlAB//2Q==' |
| 37 | + 'MAA4QklNBAQAAAAAABccAgUAC2JsdWVpbXAubmV0HAIAAAIABAD/2wCEAAEBAQEBAQEBAQEB' + |
| 38 | + 'AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB' + |
| 39 | + 'AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB' + |
| 40 | + 'AQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEB' + |
| 41 | + 'AQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAA' + |
| 42 | + 'AAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyej' + |
| 43 | + 'v8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=' |
40 | 44 | var imageUrlJPEG = 'data:image/jpeg;base64,' + b64DataJPEG
|
41 | 45 | var blobJPEG = canCreateBlob && window.dataURLtoBlob(imageUrlJPEG)
|
42 | 46 | /**
|
|
840 | 844 | expect(data.exif).to.be.ok
|
841 | 845 | expect(data.exif.get('Orientation')).to.equal(6)
|
842 | 846 | expect(img.width).to.equal(2)
|
843 |
| - expect(img.height).to.equal(1) |
844 |
| - var imageData = img.getContext('2d').getImageData(0, 0, 2, 2).data |
845 |
| - // 0:0 opaque white |
846 |
| - expect(imageData[0]).to.equal(255) |
847 |
| - expect(imageData[1]).to.equal(255) |
848 |
| - expect(imageData[2]).to.equal(255) |
| 847 | + expect(img.height).to.equal(3) |
| 848 | + // Image data layout after orientation (B=black, F=white): |
| 849 | + // BB |
| 850 | + // BF |
| 851 | + // BF |
| 852 | + var imageData = img.getContext('2d').getImageData(0, 0, 2, 3).data |
| 853 | + // 0:0 opaque black |
| 854 | + expect(imageData[0]).to.equal(0) |
| 855 | + expect(imageData[1]).to.equal(0) |
| 856 | + expect(imageData[2]).to.equal(0) |
849 | 857 | expect(imageData[3]).to.equal(255)
|
850 | 858 | // 0:1 opaque black
|
851 | 859 | expect(imageData[0 + 4]).to.equal(0)
|
852 | 860 | expect(imageData[1 + 4]).to.equal(0)
|
853 | 861 | expect(imageData[2 + 4]).to.equal(0)
|
854 | 862 | expect(imageData[3 + 4]).to.equal(255)
|
855 |
| - // 1:0 transparent black (off canvas) |
| 863 | + // 1:0 opaque black |
856 | 864 | expect(imageData[0 + 8]).to.equal(0)
|
857 | 865 | expect(imageData[1 + 8]).to.equal(0)
|
858 | 866 | expect(imageData[2 + 8]).to.equal(0)
|
859 |
| - expect(imageData[3 + 8]).to.equal(0) |
860 |
| - // 1:1 transparent black (off canvas) |
861 |
| - expect(imageData[0 + 12]).to.equal(0) |
862 |
| - expect(imageData[1 + 12]).to.equal(0) |
863 |
| - expect(imageData[2 + 12]).to.equal(0) |
864 |
| - expect(imageData[3 + 12]).to.equal(0) |
| 867 | + expect(imageData[3 + 8]).to.equal(255) |
| 868 | + // 1:1 opaque white |
| 869 | + expect(imageData[0 + 12]).to.equal(255) |
| 870 | + expect(imageData[1 + 12]).to.equal(255) |
| 871 | + expect(imageData[2 + 12]).to.equal(255) |
| 872 | + expect(imageData[3 + 12]).to.equal(255) |
| 873 | + // 2:0 opaque black |
| 874 | + expect(imageData[0 + 16]).to.equal(0) |
| 875 | + expect(imageData[1 + 16]).to.equal(0) |
| 876 | + expect(imageData[2 + 16]).to.equal(0) |
| 877 | + expect(imageData[3 + 16]).to.equal(255) |
| 878 | + // 2:1 opaque white |
| 879 | + expect(imageData[0 + 20]).to.equal(255) |
| 880 | + expect(imageData[1 + 20]).to.equal(255) |
| 881 | + expect(imageData[2 + 20]).to.equal(255) |
| 882 | + expect(imageData[3 + 20]).to.equal(255) |
865 | 883 | done()
|
866 | 884 | },
|
867 | 885 | { orientation: true }
|
|
875 | 893 | blobJPEG,
|
876 | 894 | function (img) {
|
877 | 895 | expect(img.width).to.equal(20)
|
878 |
| - expect(img.height).to.equal(10) |
| 896 | + expect(img.height).to.equal(30) |
879 | 897 | done()
|
880 | 898 | },
|
881 |
| - { orientation: true, minWidth: 20, minHeight: 10 } |
| 899 | + { orientation: true, minWidth: 20, minHeight: 30 } |
882 | 900 | )
|
883 | 901 | ).to.be.ok
|
884 | 902 | })
|
|
1027 | 1045 | loadImage(imageUrlJPEG, function (img, data) {
|
1028 | 1046 | expect(data.imageHead).to.be.undefined
|
1029 | 1047 | expect(data.exif).to.be.undefined
|
1030 |
| - expect(img.width).to.equal(1) |
1031 |
| - expect(img.height).to.equal(2) |
| 1048 | + expect(data.iptc).to.be.undefined |
1032 | 1049 | done()
|
1033 | 1050 | })
|
1034 | 1051 | ).to.be.ok
|
|
0 commit comments