Advertisement
Home Open Editor ❯

HTML canvas imageData width Property

Example

// Accessing the element
let c = document.getElementById("myCanvas");

let ctx = c.getContext("2d");
let imgData = ctx.createImageData(100, 100);

// Creating function
function myFunction(){
  alert("Width of imgData is: " + imgData.width);
}

Try this code ❯

Meaning

The imageData width canvas property returns the width of an ImageData object.


Standard Syntax

JavaScript syntax:

context.imageData.width;


Advertisement

Return Values

Value Description
number Returns in pixels.
Home Open Editor ❯
Advertisement