spelufo / books-dl

Google Books Downloader / Image Scraper
53 stars 11 forks source link

Images show as "splitted" #2

Open Milor123 opened 5 years ago

Milor123 commented 5 years ago

the images are divided in half

Example: undefined-pt3

what should I do?

gjtorikian commented 5 years ago

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 commented 4 years ago

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