HTML | canvas ImageData width Property
The ImageData width property is used to return width of an ImageData object, in pixels.
Syntax:
imgData.width;
Example:
<!DOCTYPE html> <html> <body> <h3 style="color:green">GeeksforGeeks</h3> <h3>HTML canvas ImageData width property</h3> <canvas id="myCanvas" width="200" height="200" style="border:2px solid ;"> </canvas> <p id=g eeks></p> <script> var can = document.getElementById("myCanvas"); var gfg = can.getContext("2d"); var imgData = gfg.createImageData(150, 100); var i; for (i = 0; i < imgData.data.length; i += 3) { imgData.data[i + 0] = 100; imgData.data[i + 1] = 0; imgData.data[i + 2] = 0; } gfg.putImageData(imgData, 10, 10); document.getElementById("geeks").innerHTML = "Width of imgData is: " + imgData.width </script> </body> </html> |
chevron_right
filter_none
Output:

Browsers supported:
- Chrome
- Internet Explorer 9.0
- Safari
- Firefox
- Opera
Recommended Posts:
- HTML | canvas ImageData height Property
- HTML | canvas ImageData data Property
- Web ImageData API | ImageData.width property
- Web HTMLCanvasElement API | Canvas Element width property
- HTML | <canvas> width Attribute
- Web ImageData API | ImageData.data property
- Web ImageData API | ImageData.height property
- HTML | canvas font Property
- HTML | canvas lineCap Property
- HTML | canvas lineJoin Property
- HTML | canvas shadowOffsetX Property
- HTML | canvas shadowBlur Property
- HTML | canvas textAlign Property
- HTML | canvas textBaseline Property
- HTML | canvas shadowColor Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



