Skip to content

drawImage bug in 1.2.0 #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bmustata opened this issue Feb 4, 2015 · 13 comments
Closed

drawImage bug in 1.2.0 #512

bmustata opened this issue Feb 4, 2015 · 13 comments

Comments

@bmustata
Copy link

bmustata commented Feb 4, 2015

Currently in version 1.2.0 (Linux) there is a drawImage bug where the image is not draw with it's full size when using the ctx.drawImage() command. This command is working correctly in version 1.1.6.

var Canvas = require('canvas')
, Image = Canvas.Image
, canvas = new Canvas(640, 471)
, ctx = canvas.getContext('2d')
, fs = require('fs');

fs.readFile(__dirname + '/images/capture.png', function(err, squid){
    if (err) throw err;
    img = new Image;
    img.src = squid;
    ctx.drawImage(img, 243, 95, 153, 273);

    fs.writeFile('output/out.png', canvas.toBuffer());
});
@kangax
Copy link
Collaborator

kangax commented Feb 4, 2015

/cc @woodcoder

@woodcoder
Copy link
Contributor

Is capture.png a different size to the width/height you're providing to drawImage?
And if so, is it getting clipped incorrectly?

@mattbasta
Copy link

I can confirm this issue.

@woodcoder: in the case of the images that I've seen the issue with, it happens for all calls to drawImage where the destination height and width are not the same as the source height and width. See the following examples:

Good:
good

Bad:
bad

The original images being drawn are 32x32px. The destination is 16x16px. What's interesting in this case is that the images are being clipped at the ratio of the source to the destination, but on the destination size. That is, it's clipping at 8x8 at 16x16 (2x), when the image is 16x16 scaled from 32x32.

@woodcoder
Copy link
Contributor

Are you able to try pull request #513 (or #518 which is the same fix but has an exaggerated test)? I think that should resolve it.

@mattbasta
Copy link

I haven't, but I can when I have a chance.

On Thu, Feb 19, 2015, 1:01 AM woodcoder [email protected] wrote:

Are you able to try pull request #513
#513 (or #518
#518 which is the same
fix but has additional tests)? I think that should resolve it.


Reply to this email directly or view it on GitHub
#512 (comment)
.

@mahnunchik
Copy link

Hi, any news?

@kangax
Copy link
Collaborator

kangax commented Feb 25, 2015

The (supposed) fix was already merged, so I'm just keeping it open until we release it. I just don't have time to do a release now.

@selaux
Copy link
Contributor

selaux commented Mar 13, 2015

Although the fix was merged, I still experience the issue on current master.

@bennlich
Copy link
Contributor

bennlich commented Apr 4, 2015

I was having a similar problem with the current release when using drawImage with source width and source height set to values greater than the destination width and destination height. I no longer see the clipping when using the master branch--it seems fixed.

@cambrozie
Copy link

Any update on this issue for the current release?

@tengotengo
Copy link

Still has this issue. 1.2.1

@selaux
Copy link
Contributor

selaux commented Jun 4, 2015

I don't see the commit that did it but the issue seems to be gone in 1.2.3 for me.

@LinusU
Copy link
Collaborator

LinusU commented Feb 15, 2016

Please reopen if issue persists...

@LinusU LinusU closed this as completed Feb 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants