|
106 | 106 | ).to.be.ok |
107 | 107 | }) |
108 | 108 |
|
| 109 | + it('Provide original image width+height in callback data', function (done) { |
| 110 | + expect( |
| 111 | + loadImage(imageUrlGIF, function (img, data) { |
| 112 | + expect(data.originalWidth).to.equal(60) |
| 113 | + expect(data.originalHeight).to.equal(40) |
| 114 | + done() |
| 115 | + }) |
| 116 | + ).to.be.ok |
| 117 | + }) |
| 118 | + |
109 | 119 | it('Keep object URL if noRevoke is true', function (done) { |
110 | 120 | expect( |
111 | 121 | loadImage( |
|
133 | 143 | }) |
134 | 144 | ).to.be.ok |
135 | 145 | }) |
136 | | - |
137 | | - it('Provide original image width+height in callback data', function (done) { |
138 | | - expect( |
139 | | - loadImage(imageUrlGIF, function (img, data) { |
140 | | - expect(data.originalWidth).to.equal(60) |
141 | | - expect(data.originalHeight).to.equal(40) |
142 | | - done() |
143 | | - }) |
144 | | - ).to.be.ok |
145 | | - }) |
146 | 146 | }) |
147 | 147 |
|
148 | 148 | describe('Scaling', function () { |
|
989 | 989 | }) |
990 | 990 | }) |
991 | 991 |
|
| 992 | + it('Should parse Exif tag offsets', function (done) { |
| 993 | + loadImage.parseMetaData(blobJPEG, function (data) { |
| 994 | + expect(data.exifOffsets).to.be.ok |
| 995 | + expect(data.exifOffsets.get('Orientation')).to.equal(0x16) |
| 996 | + expect(data.exifTiffOffset).to.equal(0xc) |
| 997 | + expect(data.exifLittleEndian).to.equal(false) |
| 998 | + done() |
| 999 | + }) |
| 1000 | + }) |
| 1001 | + |
992 | 1002 | it('Should parse IPTC tags', function (done) { |
993 | 1003 | loadImage.parseMetaData(blobJPEG, function (data) { |
994 | 1004 | expect(data.iptc).to.be.ok |
|
1028 | 1038 | ) |
1029 | 1039 | ).to.be.ok |
1030 | 1040 | }) |
| 1041 | + |
| 1042 | + it('Should write Exif Orientation tag and replace image head', function (done) { |
| 1043 | + loadImage( |
| 1044 | + blobJPEG, |
| 1045 | + function (img, data) { |
| 1046 | + expect(data.imageHead).to.be.ok |
| 1047 | + expect(data.exif).to.be.ok |
| 1048 | + expect(data.exif.get('Orientation')).to.equal(6) |
| 1049 | + expect(data.iptc).to.be.ok |
| 1050 | + expect(data.iptc.get('ObjectName')).to.equal('blueimp.net') |
| 1051 | + // Reset Exif Orientation data: |
| 1052 | + loadImage.writeExifData(data.imageHead, data, 'Orientation', 1) |
| 1053 | + img.toBlob(function (blob) { |
| 1054 | + loadImage.replaceHead(blob, data.imageHead, function (newBlob) { |
| 1055 | + loadImage( |
| 1056 | + newBlob, |
| 1057 | + function (img, data) { |
| 1058 | + expect(img.width).to.equal(40) |
| 1059 | + expect(img.height).to.equal(60) |
| 1060 | + expect(data.imageHead).to.be.ok |
| 1061 | + expect(data.exif).to.be.ok |
| 1062 | + expect(data.exif.get('Orientation')).to.equal(1) |
| 1063 | + expect(data.iptc).to.be.ok |
| 1064 | + expect(data.iptc.get('ObjectName')).to.equal('blueimp.net') |
| 1065 | + done() |
| 1066 | + }, |
| 1067 | + { meta: true } |
| 1068 | + ) |
| 1069 | + }) |
| 1070 | + }, 'image/jpeg') |
| 1071 | + }, |
| 1072 | + { meta: true, orientation: true, canvas: true, minWidth: 40 } |
| 1073 | + ) |
| 1074 | + }) |
1031 | 1075 | }) |
1032 | 1076 |
|
1033 | 1077 | describe('Fetch', function () { |
|
1041 | 1085 | it('Should fetch image URL as blob if meta option is true', function (done) { |
1042 | 1086 | expect( |
1043 | 1087 | loadImage( |
1044 | | - imageUrlJPEG, |
| 1088 | + // IE11 does not allow XMLHttpRequest access to data URLs, |
| 1089 | + // so we use an ObjectURL instead of imageUrlJPEG directly: |
| 1090 | + loadImage.createObjectURL(blobJPEG), |
1045 | 1091 | function (img, data) { |
1046 | 1092 | expect(data).to.be.ok |
1047 | 1093 | expect(data.imageHead).to.be.ok |
|
0 commit comments