And experimenting I did! Thanks for the GRAY tip. This is how I got it perfected. Trial & error ftw...
Reference bmp (converted from pbm) :
Code: Select all
out1.bmp BMP 1920x1080 1920x1080+0+0 1-bit PseudoClass 2c 259KB 0.000u 0:00.009
Attempt 1:
Code: Select all
$ convert -size 1920x1080 -depth 1 GRAY:random.dat out2.bmp ; identify out2.bmp
out2.bmp BMP 1920x1080 1920x1080+0+0 8-bit DirectClass 6.221MB 0.000u 0:00.009
Wrong depth in output bmp
Attempt 2:
Code: Select all
$ convert -size 1920x1080 -depth 1 -monochrome GRAY:random.dat out2.bmp ; identify out2.bmp
out2.bmp BMP 1920x1080 1920x1080+0+0 8-bit DirectClass 6.221MB 0.000u 0:00.009
Still wrong depth
Attempt 3:
Code: Select all
$ convert -size 1920x1080 -depth 1 -monochrome -type bilevel GRAY:random.dat out2.bmp ; identify out2.bmp
out2.bmp BMP 1920x1080 1920x1080+0+0 8-bit DirectClass 6.221MB 0.000u 0:00.000
And... still wrong depth
Attempt 4:
Code: Select all
$ convert -size 1920x1080 -depth 1 -monochrome -type bilevel -colors 2 GRAY:random.dat out2.bmp ; identify out2.bmp
out2.bmp BMP 1920x1080 1920x1080+0+0 1-bit PseudoClass 2c 259KB 0.000u 0:00.000
Finally! Now, perhaps I don't need all those options... Trimming:
Code: Select all
$ convert -size 1920x1080 -depth 1 -colors 2 GRAY:random.dat out2.bmp ; identify out2.bmp
out2.bmp BMP 1920x1080 1920x1080+0+0 1-bit PseudoClass 2c 259KB 0.000u 0:00.000
Great! But... the image is not identical to the reference one
At closer inspection, they look like inversed versions of each other. Ah... *one minute googling later since -inverse didn't work*
Attempt 5:
Code: Select all
$ convert -size 1920x1080 -depth 1 -colors 2 -negate GRAY:random.dat out2.bmp ; identify out2.bmp
out2.bmp BMP 1920x1080 1920x1080+0+0 1-bit PseudoClass 2c 259KB 0.000u 0:00.010
Now, the output bmp and the reference bitmap are seemingly identical. The files are not identical though - but that does not matter.
Code: Select all
out1.bmp BMP 1920x1080 1920x1080+0+0 1-bit PseudoClass 2c 259KB 0.000u 0:00.009
out2.bmp BMP 1920x1080 1920x1080+0+0 1-bit PseudoClass 2c 259KB 0.000u 0:00.010
snibgo, thanks for the rapid reply!
BTW, the random.dat is just any data. In this case it is output from /dev/urandom. To get data for a 1-bit 1920x1080 image, I just use dd:
Code: Select all
$ dd if=/dev/urandom bs=$((1920*1080/8)) count=1 of=random.dat