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

Image Size #21

Open
hipstersmoothie opened this issue Aug 1, 2018 · 4 comments
Open

Image Size #21

hipstersmoothie opened this issue Aug 1, 2018 · 4 comments

Comments

@hipstersmoothie
Copy link

const fs = require('fs')
const bmp = require('bmp-js');

const buffer = fs.readFileSync('./exampleImages/windows95.bmp')
const data = bmp.decode(buffer)

const outBuffer = bmp.encode(data)
fs.writeFileSync('test.bmp', outBuffer.data)

console.log(buffer.byteLength, data.data.byteLength, outBuffer.data.byteLength)

OUTPUT:

129078 512000 384054

almost a 3x increase!

@shaozilee
Copy link
Owner

shaozilee commented Aug 2, 2018

@hipstersmoothie Yes,your bmp file encoding with 8bit maybe,due tobmp-js's default encoding is 24bit,so you get 3x increase of bytes

@hipstersmoothie
Copy link
Author

Can i change the default encoding to match the original?

@shaozilee
Copy link
Owner

@hipstersmoothie sorry about it. I writed 24bit encoding as default encoding,not write other mode.but you can write other encoder for it.

@hipstersmoothie
Copy link
Author

do you think the current encoder could be extended to do 8 and 16 bit? or is it pretty hard coded to 24?

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