Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions js/load-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@
canvas.width,
canvas.height
)
sourceX = 0
sourceY = 0
sourceWidth = canvas.width
sourceHeight = canvas.height
img = document.createElement('canvas')
Expand Down
17 changes: 17 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,23 @@
done()
}, {sourceWidth: 40, sourceHeight: 40, crop: true, pixelRatio: 2})).to.be.ok
})

it('Crop using maxWidth/maxHeight with the given downsamplingRatio', function (done) {
expect(loadImage(blobGIF, function (img) {
expect(img.width).to.equal(10)
expect(img.height).to.equal(10)

var data = img.getContext('2d').getImageData(0, 0, 10, 10).data
for (var i = 0; i < data.length / 4; i += 4) {
expect(data[i]).to.equal(0)
expect(data[i + 1]).to.equal(0)
expect(data[i + 2]).to.equal(0)
expect(data[i + 3]).to.equal(255)
}

done()
}, {maxWidth: 10, maxHeight: 10, crop: true, downsamplingRatio: 0.5})).to.be.ok
})
})

describe('Orientation', function () {
Expand Down