I have an ImageData object but Tesseract.js only takes blob objects. How can I convert the ImageData to a blob as performantly as possible?
Convert ImageData to blob in JS?
5.8k Views Asked by AlexAndHisScripts At
2
There are 2 best solutions below
0
AlexAndHisScripts
On
Tesseract.js also takes some other types - https://github.com/naptha/tesseract.js/blob/master/docs/image-format.md - and I have found some code on the internet to convert:
function imgDataToImage(imagedata) {
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.width = imagedata.width;
canvas.height = imagedata.height;
ctx.putImageData(imagedata, 0, 0);
var image = new Image();
image.src = canvas.toDataURL();
return image;
}
Related Questions in JAVASCRIPT
- Angular Show All When No Filter Is Supplied
- Why does a function show up as not defined
- I count the time the user takes to solve my quiz using Javascript but I want the same time displayed on another page
- Set "More" "Less" font size
- Using pagination on a table in AngularJS
- How to sort these using Javascript or Jquery Most effectively
- how to fill out the table with next values in array with one button
- State with different subviews
- Ajax jQuery firing multiple time display event for the same result
- Getting and passing MVC Model data to AngularJS controller
- Disable variable in eval
- javascript nested loops waiting for user input
- .hover() seems to overwrite .click()
- How to sort a multi-dimensional array by the second array in descending order?
- How do I find the fonts that are not loading in a CORS situation ( MoovWeb )?
Related Questions in BLOB
- Sending blob data via ajax
- Loading binary image data to an image fails on Android 4.1 in Cordova Project
- Why throwing java.lang.IndexOutOfBoundsException when reading blob in the database hsqldb
- I want to remove all BLOBs from a table - set to NULL or EMPTY_BLOB?
- Save File in javascript clientside using utf-8 string
- Blob createObjectURL download not working in Firefox (but works when debugging)
- A C cgi script to serve binary file from sqlite3_column_blob pointer
- How to get HTML <video> data as a blob in JS?
- OpenCV return keypoints coordinates and area from blob detection, Python
- Server side to upload file through jQuery Ajax
- "Access is Denied" when embedding file from blob URL in IE
- How to include the image from byte array with other content in codeigniter?
- Uploading file to MySQL blob field file_get_contents(): failed (from input type="file")
- CLOB value in out/return from plsql (invalid LOB locator specified: ORA-22275)
- In Oracle, how to select LOBs from remote database without copying to local tables?
Related Questions in DATA-CONVERSION
- Mysql cell conversion
- Binary to CSV record Converstion
- Converting data structures to other data structures
- Which encoding replaces "í" with "\303 \255"?
- Converting a 'long' type into a binary String
- Convert .mat files to signal .slx file
- How to convert a Numpy array (Rows x Cols) to an array of XYZ coordinates?
- Converting "weekstring" to enum
- C# List which could contain only image or string
- byte array with variable length to number
- Convert nested JSON to CSV file in Python
- Convert Date format in shell
- Why is my preferences data being returned as an array instead of a string?
- Converting .fasta files to .gff3 files
- Converting String To Float number in android
Related Questions in TESSERACT.JS
- Tesseract.js - Not working first time
- OCR, tesseract.js: How do I match values to labels?
- TypeError: createWorker is not a constructor
- Want to parse arabic and english from an image
- Convert ImageData to blob in JS?
- How can I package an electron app with OCR features?
- Tesseract.js error handling - I can't catch the error in worker.recognize()
- how to use tessdata_best for tesseract (pytesseract). What are the arguments and procedure?
- "Uncaught (in promise) TypeError: Cannot read property 'postMessage' of null" when I terminate Tesseract worker in VueJS 2
- How to suppress logs in tesseract.js
- Aborted(Error: ENOENT: no such file or directory[...])
- Rendering logger output to component on Tesseract.js (with React) slows down
- Using 'preserve_interword_spaces' in tesseract.js
- Angular + Tesseract.js (and opencv.js)
- Chrome Extension - Unable to load local Tesseract.js worker.min.js due to Content Security Policy (Manifest v3)
Related Questions in IMAGEDATA
- How to get any type of images creation date and time in php
- How to import image dataset from folder with tensorflowio
- Convert ImageData to blob in JS?
- C# on linux: FFmpeg (FFMediaToolkit) MediaOutput..Video.AddFrame(FrameToImageData(ImageData)) causes program to exit with code 139
- Keras : Dealing with large image datasets
- How can I grayscale a canvas image in JavaScript?
- How do you write ImageData to an HTML5 canvas context?
- Get full ImageData after Panning the image inside Cavnas
- How to know ImageDataGenerator() assigns which label to which image class?
- ram crashed while using imagedatagenerator in google colab
- where does leaflet store the tiles for a tilelayer
- Array of ImageData data is not equal to array literal
- what does "imageData[ (width + height * stageHeight) * 4 -1 ]" mean?
- It is possible to insert image into pandas data frame?
- Convert ImageData to ImageBytes in ActiveReports 16
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Referring here, the code should look like -