I have a program that copies each pixel onto another picture with the same size:
The expected behavior is that the input.bmp should be cloned and saved as output.bmp
The output image is not exactly the input file.
const Jimp = require('jimp');
async function program() {
const input = await Jimp.read('input.bmp');
const output = await Jimp.create(input.getWidth(), input.getHeight());
for (let y = 0; y < input.getHeight(); y++) {
for (let x = 0; x < input.getWidth(); x++) {
output.setPixelColor(input.getPixelColor(x, y), x, y);
}
}
await output.writeAsync('output.bmp');
}
program();
Screenshots
For some reasons, GitHub doesn't allow to upload BMP files. Here's the link to both files:
I just tried clone() function and it resulted with the same issue:
const Jimp = require('jimp');
async function program() {
const input = await Jimp.read('input.bmp');
const output = input.clone();
await output.writeAsync('output.bmp');
}
program();
An update.
The issue seems to be in decoding BMP files created using GIMP.
I face no issues if the input BMP was created using JIMP library.
The issue arises when an image is exported as BMP using GIMP and color space information is written to it.
To avoid this issue, select "Do not write color space information" under "Compatibility Options" when exporting as BMP.
Most helpful comment
The issue arises when an image is exported as BMP using GIMP and color space information is written to it.
To avoid this issue, select "Do not write color space information" under "Compatibility Options" when exporting as BMP.