Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/naptha/tesseract.js.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalearica <admin@scribeocr.com>2022-08-11 09:28:53 +0300
committerGitHub <noreply@github.com>2022-08-11 09:28:53 +0300
commita9ac00ccac5527afacd556586fdca00fbe3c4fe7 (patch)
tree77b15da2b47d98210ce768e636df39ef834e6364
parent75ddd6304109434a66064485bdaa23fb893990fa (diff)
Removed exif auto-rotation for browser per #604 (#634)
-rw-r--r--src/worker/browser/loadImage.js36
1 files changed, 7 insertions, 29 deletions
diff --git a/src/worker/browser/loadImage.js b/src/worker/browser/loadImage.js
index 3102967..2223d4f 100644
--- a/src/worker/browser/loadImage.js
+++ b/src/worker/browser/loadImage.js
@@ -1,5 +1,4 @@
const resolveURL = require('resolve-url');
-const blueimpLoadImage = require('blueimp-load-image');
/**
* readFromBlobOrFile
@@ -21,19 +20,6 @@ const readFromBlobOrFile = (blob) => (
})
);
-const fixOrientationFromUrlOrBlobOrFile = (blob) => (
- new Promise((resolve) => {
- blueimpLoadImage(
- blob,
- (img) => img.toBlob(resolve),
- {
- orientation: true,
- canvas: true,
- },
- );
- })
-);
-
/**
* loadImage
*
@@ -48,18 +34,14 @@ const loadImage = async (image) => {
}
if (typeof image === 'string') {
- if (image.endsWith('.pbm')) {
+ // Base64 Image
+ if (/data:image\/([a-zA-Z]*);base64,([^"]*)/.test(image)) {
+ data = atob(image.split(',')[1])
+ .split('')
+ .map((c) => c.charCodeAt(0));
+ } else {
const resp = await fetch(resolveURL(image));
data = await resp.arrayBuffer();
- } else {
- let img = image;
- // If not Base64 Image
- if (!/data:image\/([a-zA-Z]*);base64,([^"]*)/.test(image)) {
- img = resolveURL(image);
- }
- data = await readFromBlobOrFile(
- await fixOrientationFromUrlOrBlobOrFile(img),
- );
}
} else if (image instanceof HTMLElement) {
if (image.tagName === 'IMG') {
@@ -77,11 +59,7 @@ const loadImage = async (image) => {
});
}
} else if (image instanceof File || image instanceof Blob) {
- let img = image;
- if (!image.name.endsWith('.pbm')) {
- img = await fixOrientationFromUrlOrBlobOrFile(img);
- }
- data = await readFromBlobOrFile(img);
+ data = await readFromBlobOrFile(image);
}
return new Uint8Array(data);