Okay. Yes I found the code that extracts an offset from the "size" setting. Learn something new every-day!
Adding that info to IM Examples, Formats, Raw Image Data. (give it an hour or two to appear)
http://www.imagemagick.org/Usage/formats/#rgb
Hmmm.. It with a quick look at the source the offset appears to be bytes, so that is good.
Smaller test image (raw data)
Code: Select all
convert -size 100x100 xc: -draw 'circle 25,25 20,5' -depth 16 -endian MSB gray:image_data.raw
File is 20000 bytes... 100x100x2 -> 20000 bytes
prepend some junk (23 bytes including a newline character)
Code: Select all
echo "this is raw image data" > image_data_offset.raw
cat image_data.raw >> image_data_offset.raw
now read back using offset..
Code: Select all
convert -size 100x100+23 -depth 16 -endian MSB gray:image_data_offset.raw show:
Perfect image return!
Without the offset I get junk for the first few pixels, and fuzzy circle off set to right by 12 pixels.
The fuzziness is because 23 bytes is not divisible by two, so the 2 byte gray values are in the wrong order. However as the test image is black and white so results are still vaguely visible.
With an offset that is to big... EG: 51 bytes (odd so as to re-align the 2-yte endian), the circle is clear but shifted left 12 pixels ( (51-23) / 2 -> 12 pixels) but the whole last row is black, and IM produced an error (exception)...
convert: unexpected end-of-file `image_data_offset.raw': No such file or directory @ error/gray.c/ReadGRAYImage/206.
The "No such file or directory" part of the error message is rather mis-leading, but the error "unexpected end-of-file" is exactly the reason for the failure. Basically it did not find enough data!