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 answers
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
- Using Puppeteer to scrape a public API only when the data changes
- inline SVG text (js)
- An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
- Storing the preferred font-size in localStorage
- Simple movie API request not showing up in the console log
- Authenticate Flask rest API
- Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
- How to request administrator rights?
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- In Datatables, start value resets to 0, when column sorting
- How do I link two models in mongoose?
- parameter values only being sent to certain columns in google sheet?
- Run main several times of wasm in browser
- Variable inside a Variable, not updating
Related Questions in BLOB
- Out of memory while adding documents to a Firebird BLOB field with Delphi
- Data migration from Oracle Database Clob to GCP Bucket
- want stand logic app or function app (not premium) to connect to a blob storage which is under a vnet. How to achieve this?
- Is it possible to open a blob without saving it to file
- How do I add various document types to a Firebird BLOB field with Delphi
- Embedded pdf-file to blob with Python Selenium
- Sending an image (png) from my back (Java spring) to the front (react) and printing it
- SQLite query not returning expected results despite correct hashing and comparison in Android application
- display image in react as png/jpg went wrong
- Undeleting an Azure Blob Using a REST API Call from PowerShell
- How to pass multer file data into LangChain.js WebPDFLoader correctly?
- React-native 'name is null' when playing Sound from a fetched file
- Logic app blob trigger retry policy not working for 503 error
- What is the Right way to pass credentials to python libraries like adls-fsspec?
- Broken uploaded images in Vercel Blob via Express JS
Related Questions in DATA-CONVERSION
- Is there a way to convert unknow file type to human readable format?
- SSIS Data Conversion Error: Overflow Issue in Automated Job Execution
- saving float array to ascii
- Converting a dataframe into a long format contingency table for network analysis purposes
- Glulxe/gblorb game or file editing
- Concatenating two bytes of a can frame with multiplexed message
- In PHP, how do I make appropriate data conversions on items in an array so that they suit MariaDB syntax?
- pd.read_html mangles a table header, and adds the entire content of an inner table in the top cell
- JAVA : On Converting Json Element to an Object, Integer value gets Converted to Double
- Convert an INT value to a decimal with 2dp
- Trying to convert reassigning declared variables SQL code to Snowflake
- How to convert a json array to relational data in oracle
- Substracting time values from csv file by python
- How to turn a data frame into a table
- Define a class in Python and import into Rust module, but it "cannot be converted"
Related Questions in TESSERACT.JS
- How can i split the text from a conversation into sender and reciver
- Want to parse arabic and english from an image
- How to perform OCR from image URI in React native expo?
- Highlight the text in image using tesseract.js
- Tesseract JS is having issues finding text in an image
- TypeError: worker.load is not a function
- how to convert two/there column images to text with ( tesseract.js ocr)?
- How can I fix the error 'webpack_require__.g.addEventListener is not a function' in Tesseract.js with Electron and webpack?
- ReferenceError: Property 'document' doesn't exist
- Tesseract.js not recognizing picture in an PWA App
- Aborted(Error: ENOENT: no such file or directory[...])
- How to get the result value number that maybe in any part of a string?
- i want to convert this react js code and put it in angular component
- Object Promise returned and output rather than value
- Tesseract.js does not work on local files
Related Questions in IMAGEDATA
- No evaluator found. Use `DefaultTrainer.test(evaluators=)`, or implement its `build_evaluator` method
- How to output ImageData as a BMP image in Java
- How do I decode Base64 encoded PNG manually in C#?
- imageData on paletted png results in nearly duplicate colors
- Matlab, ImageDataStore 'not allowed' error
- FixError: TypeError: Size should be int or sequence. Got <class 'dict'>
- ImageData is different when getting one pixel
- How do I compress a large ImageData object into a manageable string that can be decompressed for later use?
- How do I accept file uploads from pasting a file into the browser?
- AJAX receiving null data when a massive string is sent
- Find a string stored in a image data type in sql
- Convert ImageData to ImageBytes in ActiveReports 16
- It is possible to insert image into pandas data frame?
- what does "imageData[ (width + height * stageHeight) * 4 -1 ]" mean?
- where does leaflet store the tiles for a tilelayer
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?
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)
Referring here, the code should look like -