correctly get width and height from canvas