8

PocketBook 611 is a black-and-white e-book reader. PocketBook 611 (and models of similar age, before touch displays were introduced) uses a very specific BMP format for its so-called "Power-off Logo" (wallpaper for e-ink display, when it is turned off).

I am able to create compatible BMP files using Paint.NET, but I would like to automate my workflow and use ImageMagick instead. The correct BMP format is detected by file as:

$ file good.bmp 
good.bmp: PC bitmap, Windows 3.x format, 600 x 800 x 8, resolution 3779 x 3779 px/m, 256 important colors, cbSize 481078, bits offset 1078

But when I am creating BMP files using ImageMagick (e.g. convert input.jpg output.bmp), I get an error on the PocketBook about incompatible bitmap image format.

1 Answer 1

18

Use the following convert command:

convert input.jpg -type Grayscale -colorspace Gray -colors 255 -compress None BMP3:output.bmp

Replace convert with magick if your ImageMagick installation doesn't include convert.

In script form for automation:

#!/usr/bin/env bash

if [[ $# -lt 1 ]]
then
    echo "Specify filename"
    exit 1
fi

while [[ $# -gt 0 ]]
do
    from="$1"
    to="${1%.*}.bmp"
    shift
    echo "'$from' -> '$to'"
    convert "$from" -type Grayscale -colorspace Gray \
        -colors 255 -compress None BMP3:"$to"
done

The script can be used in a directory of input files like so: ./pocketbook-convert.sh *.jpg *.png

If the images are already cropped and rotated, ImageMagick can also resize them to the correct size:

convert "$from" \
  -gravity center -resize 600x800^ -extent 600x800 \
  -type Grayscale -colorspace Gray -colors 255 -compress None BMP3:"$to"

Explanation

Prefix BMP3: is needed to specify version of BMP format, because by default regular BMP is used, which is BMP version 4. See also list of formats via identify -list format:

$ identify -list format | grep BMP
      BMP* BMP       rw-   Microsoft Windows bitmap image
     BMP2* BMP       rw-   Microsoft Windows bitmap image (V2)
     BMP3* BMP       rw-   Microsoft Windows bitmap image (V3)
     WBMP* WBMP      rw-   Wireless Bitmap (level 0) image

I figured out the exact parameters for other options by comparing output of identify -verbose between a good file and a bad file. Also, this answer about DirectClass and PseudoClass helped understand what's going on with color maps and color spaces. Relevant parts of output of identify -verbose:

$ identify -verbose good.bmp | less
  Format: BMP3 (Microsoft Windows bitmap image (V3))
  Class: PseudoClass
  Colorspace: sRGB
  Type: Grayscale
  Colors: 250
  Compression: None
  Filesize: 481078B

Filesize is relevant, because with "correct" options, all files have almost exact same size around 470 kilobytes.

Documentation of grayscale BMP conversion options: -type Grayscale, -colorspace Gray, -colors 255, and -compress None.

Documentation of resizing options: -gravity (has to go before -extent!), -resize, -extent.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .