Skip to content

Instantly share code, notes, and snippets.

@greymd
Created September 14, 2017 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greymd/cfc37da72e7f2313b70d56eb68e6f0dc to your computer and use it in GitHub Desktop.
Save greymd/cfc37da72e7f2313b70d56eb68e6f0dc to your computer and use it in GitHub Desktop.
Bmp file analysis with ShellScript
# Extract size from information header. 14 is the octet length of file header.
od -tx1 -An flower.bmp \
| tr -dc 'a-z0-9' \
| fold -w 2 \
| sed -n '14,15p' \
| tr -d '\n' \
| sed 's/./\U&/g;s/^/obase=10;ibase=16;/' \
| awk 1 \
| bc \
| awk '{print $1+14}'
# File header -- 14 bytes
# Info header -- 124 bytes.
od -tx1 -An flower.bmp | tr -dc 'a-z0-9' | fold -w 2 | sed -n '139,$p' | tr -d '\n' | fold -w 6 | nl
##
## 307200 -- 640 * 480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment