Convert to binary and save to database

6 ビュー (過去 30 日間)
oztex smiith
oztex smiith 2021 年 11 月 10 日
コメント済み: oztex smiith 2021 年 11 月 11 日
For my recent project, i will have to deal with plenty of images. With a view to making server respond faster, I decided to save images in the form of binary numbers. Is there any way I could create a binary converter with the help of math algorithm?

採用された回答

Yongjian Feng
Yongjian Feng 2021 年 11 月 10 日
Are you talking about image formats here? For binary, do you mean bitmap?
  2 件のコメント
oztex smiith
oztex smiith 2021 年 11 月 11 日
I don't know about bitmap but I'm going to research on that. But, I have read that Mongodb uses binary numbering system to save images with a view to make it faster. Since, binary contains zeros and ones, it occupies lesser memory and improves page loading speed.
oztex smiith
oztex smiith 2021 年 11 月 11 日
Actually, i just found a node.js package for the same conversion: https://www.npmjs.com/package/b2tconverter and the website, https://binarytotext.net
i have gone through the working, this is the code i found for image to binary conversion:
var file = inputElement.files[0];
var reader = new FileReader();
reader.onloadend = function() {
console.log('Encoded Base 64 File String:', reader.result);
/******************* for Binary ***********************/
var data=(reader.result).split(',')[1];
var binaryBlob = atob(data);
console.log('Encoded Binary File String:', binaryBlob);
}
reader.readAsDataURL(file);
Once, I will get the binary conversion, I will save binary into database. I'm going to implement this tomorrow and I'm optimistic that will find the solution.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by