A followup.
I was using MagickSetImageProperty(m_wand,"caption","%f %wx%h") to set the caption for the polaroid but after some testing and reading the IM code it appears that the command line must be using MagickSetOption(m_wand,"caption","%f %wx%h").
When using MagickSetOption, it must be called before MagickReadImage (and on the command line -caption must precede the input image) or else it is ignored. But when using MagickSetImageProperty it must follow MagickReadImage.
They both appear to set the same thing but are handled slightly differently because before the fix to the code that you suggested, MagickSetOption would cause a caption with the correct image size information but MagickSetImageProperty gave a height of one (with the fix they're both correct).
Since the command line uses MagickSetOption I presume this is the correct function to use in this situation but what is the difference between the two?
And BTW, there's no entry for -caption in
http://imagemagick.org/script/command-line-options.php
Pete