Reference implementation C programs to return image dimensions of:
- jpg
- webp
- png
- bmp
- gif
<bmp|gif|jpg|png|webp>dims <image.$1>pngdims input.pngw: %i h: %ie.g. gcc
# for webpdims...
gcc -O2 -o webpdims webpdims.c
Modify printf output and recompile.
Implementation is designed for modifcation and recompilation, as opposed to filtering output and remapping for purpose. High performance application target.
Notes:
png uses a fixed binary header strucure, and allows the fastest parsing.
Webp uses three internal payload structures, so it's slightly less efficient than png, which should be considered, ideal.
Jpeg uses SOF blocks to contain header info.
File integrity (i.e. is this a png? etc), upsteam concern.