MagickPolaroidImage caption problem

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

MagickPolaroidImage caption problem

Post by el_supremo »

When using a "%wx%h" caption with MagickPolaroidImage (in C and ImageMagick 6.3.5 07/31/07 Q8) it always prints the height as 1 but on the command line I get the right info.
I can't figure out why there's a difference, but in the PolaroidImage function in fx.c there is this statement:

Code: Select all

      /*
        Generate caption image.
      */
      caption_image=CloneImage(image,image->columns,1,MagickTrue,exception);
which explicitly uses a height of one and caption_image is then used to determine the values of the caption string.
Is this correct?

Pete
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickPolaroidImage caption problem

Post by magick »

A few lines down you will find a call to InterpretImageProperties(). Change the caption_image parameter to image and see if that fixes the problem.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: MagickPolaroidImage caption problem

Post by el_supremo »

Yes, that fixes the problem.

Thanks
Pete
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: MagickPolaroidImage caption problem

Post by el_supremo »

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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickPolaroidImage caption problem

Post by magick »

In general, use MagickSetOption() to set key/value pairs before an image is read and MagickSetImageProperty() after the image is read (as you correctly surmised). We use the MagickCore API SetImageOption() method when interpretting the command the line because caption behaves as a setting not an image operator. After the image is read the caption is interpreted and saved as an image property (e.g. %wx%h, see ReadImage() in magick/constitute.c for details). So for MagickPolaroidImage() the proper method to set the caption is MagickSetImageProperty().
Post Reply