Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
HTMLImageElement vs HTMLCanvasElement vs ImageBitmap Forked
(version: 1)
CanvasRenderingContext2d::drawImage with HTMLImageElement vs HTMLCanvasElement vs ImageBitmap
Comparing performance of:
HTMLImageElement vs HTMLCanvasElement vs ImageBitmap
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var natrualWidth = 0, naturalHeight = 0, eleImg = document.createElement("img"), cvsImg = document.createElement("canvas"), bmpImg = null, canvasEleImg = document.createElement("canvas"), canvasCvsImg = document.createElement("canvas"), canvasBmpImg = document.createElement("canvas"), ctxEleImg = canvasEleImg.getContext("2d"), ctxCvsImg = canvasCvsImg.getContext("2d"), ctxBmpImg = canvasBmpImg.getContext("2d"), doneLoading = false; canvasEleImg.width = canvasBmpImg.width = canvasCvsImg.width = 640; canvasEleImg.height = canvasBmpImg.height = canvasCvsImg.height = 480; eleImg.addEventListener("load", function() { cvsImg.width = naturalWidth = eleImg.naturalWidth; cvsImg.height = naturalHeight = eleImg.naturalHeight; cvsImg.getContext("2d").drawImage(eleImg, 0, 0, natrualWidth, naturalHeight, 0, 0, natrualWidth, naturalHeight); Promise.all([ createImageBitmap(img) ]).then(function(images) { imageBitmap = images[0]; doneLoading = true; }, false); }); eleImg.src = "https://new.imagehostx.com/upload/2025/02/22/e5306382-3a31-4214-bbcf-b1661db689cb_1740191464.jpg";
Tests:
HTMLImageElement
if (doneLoading) ctxEleImg.drawImage(eleImg, 0, 0, natrualWidth, naturalHeight, 0, 0, natrualWidth, naturalHeight);
HTMLCanvasElement
if (doneLoading) ctxCvsImg.drawImage(cvsImg, 0, 0, natrualWidth, naturalHeight, 0, 0, natrualWidth, naturalHeight);
ImageBitmap
if (doneLoading) ctxBmpImg.drawImage(bmpImg, 0, 0, natrualWidth, naturalHeight, 0, 0, natrualWidth, naturalHeight);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
HTMLImageElement
HTMLCanvasElement
ImageBitmap
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:146.0) Gecko/20100101 Firefox/146.0
Browser/OS:
Firefox 146 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
HTMLImageElement
627005760.0 Ops/sec
HTMLCanvasElement
628495104.0 Ops/sec
ImageBitmap
625533056.0 Ops/sec
Related benchmarks:
HTMLImageElement vs HTMLCanvasElement vs ImageBitmap
Image vs ImageBitmap vs cv with context2d
Image vs ImageBitmap vs canvas with context2d
Image vs canvas with 2d
Canvas vs img
canvas2d.drawImage(imageElement) vs createImageBitmap(imageElement) (v321)
tailnh-test2
HTMLImageElement vs HTMLCanvasElement vs ImageBitmap, using placekitten
putImageData vs drawImage methods
Comments
Confirm delete:
Do you really want to delete benchmark?