Automattic / Automattic/node-canvas
Set dimensions for an image object
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 1
Description
I've using node-canvas with resemble.js. However I've noticed some differences in the actual result of the image comparison between a real browser and Node. The only thing I've found so far that differs is the following lines of code.
```
var hiddenImage = new Image();
hiddenImage.src = fileData;
...
hiddenImage.width = images[0].width;
hiddenImage.height = images[0].height;
...
hiddenCanvas.getContext('2d').drawImage(hiddenImage, 0, 0, width, height);
```
I'm not sure that you should actually be able to do it. Cause I don't find any documentation on what you can actually do with the image object. So some clarification on that would be nice.
## Issue or Feature
The problem is that the hiddenImage has the same dimensions after I've tried to set them to new values.
So when the image is drawn on the canvas it will have the wrong dimensions. And therefore the comparison fails.
## Steps to Reproduce
```js
var hiddenImage = new Image();
hiddenImage.src = fileData;
...
hiddenImage.width = images[0].width;
hiddenImage.height = images[0].height;
...
hiddenCanvas.getContext('2d').drawImage(hiddenImage, 0, 0, width, height);
```
## Your Environment
* Version of node-canvas (e.g. 1.4.0): 1.6.2
* Environment (e.g. node 4.2.0 on Mac OS X 10.8): Node 7.2.0 Window 10 x64
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.