Skip to content

Commit f60a8ce

Browse files
committed
Use a smaller, black+white JPEG test image.
1 parent 452adbf commit f60a8ce

File tree

1 file changed

+51
-35
lines changed

1 file changed

+51
-35
lines changed

test/test.js

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,20 @@
2323
'ovGITCqXzKbzCY1Kp9Sq9YrNarfcrvcLDovH5PKsAAA7'
2424
var imageUrlGIF = 'data:image/gif;base64,' + b64DataGIF
2525
var blobGIF = canCreateBlob && window.dataURLtoBlob(imageUrlGIF)
26-
// 2x1px JPEG (color white, with the Exif orientation flag set to 6 and the
27-
// IPTC ObjectName (2:5) set to 'objectname'):
26+
// black/white 1x2px JPEG, with the following meta information set:
27+
// - EXIF Orientation: 6 (Rotated 90° CCW)
28+
// - IPTC ObjectName: blueimp.net
29+
// Meta information has been set via exiftool (exiftool.org):
30+
// exiftool -all= -Orientation#=6 -YCbCrPositioning= -ResolutionUnit= \
31+
// -YResolution= -XResolution= -ObjectName=blueimp.net black+white-1x2.jpg
2832
var b64DataJPEG =
29-
'/9j/4AAQSkZJRgABAQEAYABgAAD/4QAiRXhpZgAASUkqAAgAAAABABIBAwABAAAA' +
30-
'BgASAAAAAAD/7QAsUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAA8cAgUACm9iamVj' +
31-
'dG5hbWUA/9sAQwABAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB' +
32-
'AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB/9sAQwEBAQEBAQEBAQEBAQEBAQEB' +
33-
'AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB' +
34-
'/8AAEQgAAQACAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYH' +
35-
'CAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGh' +
36-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lAB//2Q=='
4440
var imageUrlJPEG = 'data:image/jpeg;base64,' + b64DataJPEG
4541
var blobJPEG = canCreateBlob && window.dataURLtoBlob(imageUrlJPEG)
4642
/**
@@ -646,15 +642,14 @@
646642
function (img) {
647643
expect(img.width).to.equal(10)
648644
expect(img.height).to.equal(10)
649-
650-
var data = img.getContext('2d').getImageData(0, 0, 10, 10).data
651-
for (var i = 0; i < data.length / 4; i += 4) {
652-
expect(data[i]).to.equal(0)
653-
expect(data[i + 1]).to.equal(0)
654-
expect(data[i + 2]).to.equal(0)
655-
expect(data[i + 3]).to.equal(255)
645+
var imageData = img.getContext('2d').getImageData(0, 0, 10, 10).data
646+
// Check if all image pixels are opaque black (0, 0, 0, 255):
647+
for (var i = 0; i < imageData.length / 4; i += 4) {
648+
expect(imageData[i]).to.equal(0)
649+
expect(imageData[i + 1]).to.equal(0)
650+
expect(imageData[i + 2]).to.equal(0)
651+
expect(imageData[i + 3]).to.equal(255)
656652
}
657-
658653
done()
659654
},
660655
{ maxWidth: 10, maxHeight: 10, crop: true, downsamplingRatio: 0.5 }
@@ -844,8 +839,29 @@
844839
expect(data).to.be.ok
845840
expect(data.exif).to.be.ok
846841
expect(data.exif.get('Orientation')).to.equal(6)
847-
expect(img.width).to.equal(1)
848-
expect(img.height).to.equal(2)
842+
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)
849+
expect(imageData[3]).to.equal(255)
850+
// 0:1 opaque black
851+
expect(imageData[0 + 4]).to.equal(0)
852+
expect(imageData[1 + 4]).to.equal(0)
853+
expect(imageData[2 + 4]).to.equal(0)
854+
expect(imageData[3 + 4]).to.equal(255)
855+
// 1:0 transparent black (off canvas)
856+
expect(imageData[0 + 8]).to.equal(0)
857+
expect(imageData[1 + 8]).to.equal(0)
858+
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)
849865
done()
850866
},
851867
{ orientation: true }
@@ -858,11 +874,11 @@
858874
loadImage(
859875
blobJPEG,
860876
function (img) {
861-
expect(img.width).to.equal(10)
862-
expect(img.height).to.equal(20)
877+
expect(img.width).to.equal(20)
878+
expect(img.height).to.equal(10)
863879
done()
864880
},
865-
{ orientation: true, minWidth: 10, minHeight: 20 }
881+
{ orientation: true, minWidth: 20, minHeight: 10 }
866882
)
867883
).to.be.ok
868884
})
@@ -942,7 +958,7 @@
942958
it('Should parse IPTC tags', function (done) {
943959
loadImage.parseMetaData(blobJPEG, function (data) {
944960
expect(data.iptc).to.be.ok
945-
expect(data.iptc.get('ObjectName')).to.equal('objectname')
961+
expect(data.iptc.get('ObjectName')).to.equal('blueimp.net')
946962
done()
947963
})
948964
})
@@ -971,7 +987,7 @@
971987
expect(data.exif).to.be.ok
972988
expect(data.exif.get('Orientation')).to.equal(6)
973989
expect(data.iptc).to.be.ok
974-
expect(data.iptc.get('ObjectName')).to.equal('objectname')
990+
expect(data.iptc.get('ObjectName')).to.equal('blueimp.net')
975991
done()
976992
},
977993
{ meta: true }
@@ -998,7 +1014,7 @@
9981014
expect(data.exif).to.be.ok
9991015
expect(data.exif.get('Orientation')).to.equal(6)
10001016
expect(data.iptc).to.be.ok
1001-
expect(data.iptc.get('ObjectName')).to.equal('objectname')
1017+
expect(data.iptc.get('ObjectName')).to.equal('blueimp.net')
10021018
done()
10031019
},
10041020
{ meta: true }
@@ -1011,8 +1027,8 @@
10111027
loadImage(imageUrlJPEG, function (img, data) {
10121028
expect(data.imageHead).to.be.undefined
10131029
expect(data.exif).to.be.undefined
1014-
expect(img.width).to.equal(2)
1015-
expect(img.height).to.equal(1)
1030+
expect(img.width).to.equal(1)
1031+
expect(img.height).to.equal(2)
10161032
done()
10171033
})
10181034
).to.be.ok

0 commit comments

Comments
 (0)