Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有没有获取 Base64 数据的接口 #62

Closed
Manjiz opened this issue Dec 9, 2015 · 2 comments
Closed

有没有获取 Base64 数据的接口 #62

Manjiz opened this issue Dec 9, 2015 · 2 comments

Comments

@Manjiz
Copy link

Manjiz commented Dec 9, 2015

图片处理之后,我不想保存到文件,而是想获取一段base64数据。

@hungchai
Copy link

Just seen your question, Nodejs has built-in function to do this.

var toBase64 = imgbuffer.toString('base64');

@Manjiz
Copy link
Author

Manjiz commented Dec 24, 2015

@hungchai Thanks a lot. I found this. So I do not need to save the img file first.

.encode(type[, config])
eg:images("input.png").encode("jpg", {operation:50}) Encode image to buffer, config is image setting.
以指定格式编码当前图像到Buffer,config为图片设置,目前支持设置JPG图像质量
Return buffer
返回填充好的Buffer

And code .encode("jpg", {operation:50}).toString('base64'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants