Skip to content
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

Images show as "splitted" #2

Open
Milor123 opened this issue Oct 24, 2018 · 2 comments
Open

Images show as "splitted" #2

Milor123 opened this issue Oct 24, 2018 · 2 comments

Comments

@Milor123
Copy link

Milor123 commented Oct 24, 2018

the images are divided in half

Example:
undefined-pt3

what should I do?

@gjtorikian
Copy link

For what it's worth, I had to double this by adding width * 2 :

-var makeImgDataGetter = function (canvas) {
-  return function (img) {
-    canvas.setAttribute('width', img.width)
-    canvas.setAttribute('height', img.height)
+var makeImgDataGetter = function(canvas) {
+  return function(img) {
+    canvas.setAttribute("width", img.width * 2);
+    canvas.setAttribute("height", img.height);
     var context = canvas.getContext("2d");
     context.drawImage(img, 0, 0);
-    return context.getImageData(0, 0, img.width, img.height);
-  }
-}
+    return context.getImageData(0, 0, img.width * 2, img.height);
+  };
+};

@gregorbg
Copy link

For anyone else stumbling upon this problem: Replace img.height and img.width with img.naturalHeight and img.naturalWidth respectively

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

3 participants