Skip to content Skip to sidebar Skip to footer

How To Convert Image Into Byte Array In Jsp/javascript

hi i am acquiring the image from the scanner device successfully i want to store that image in data base i am thinking that i need to convert into byte array then pass to controll

Solution 1:

You can get the image binary in BASE64 format. The imgObj.data in below code is the BASE64 format of image object:

functionaddImage(imgObj, domParent) {
        imagesScanned.push(imgObj);
        var imgSrc = imgObj.datatype == com_asprise_scan_datatype_BASE64 ? 'data:'
                + imgObj.mimetype + ';base64,' + imgObj.data
                : imgObj.data;
         ...

To get the actual binary bytes, you can use:

var bin = window.atob(imgObj.data)

For a complete discussion of converting BASE64 to binary, please refer to: Base64 encoding and decoding in client-side Javascript

For a complete usage of scanner.js, you may consult Developer guide to scanner.js: cross-Browser HTML/JavaScript Scanning - Acquires images from scanners to web pages (Java, C# ASP.NET, PHP)

Post a Comment for "How To Convert Image Into Byte Array In Jsp/javascript"