Setting caption font properties using MagickWand API
Setting caption font properties using MagickWand API
How are caption: font type, font color and other font properties set using MagickWand API?
Mikko Koppanen
My blog: http://valokuva.org
My blog: http://valokuva.org
Re: Setting caption font properties using MagickWand API
Well, I had some extra time during the evening so I came up with this solution: Adding MagickSetFont and MagickSetFontSize to wand/magick-property.
This however does not seem to be a complete solution (MagickSetFontFamily? Font color?). I got a semi-ready patch for adding MagickSetFont and MagickSetFontSize, so drop me a note if this seems like a reasonable approach and I will continue my work on them.
This however does not seem to be a complete solution (MagickSetFontFamily? Font color?). I got a semi-ready patch for adding MagickSetFont and MagickSetFontSize, so drop me a note if this seems like a reasonable approach and I will continue my work on them.
Mikko Koppanen
My blog: http://valokuva.org
My blog: http://valokuva.org
Re: Setting caption font properties using MagickWand API
Post your patches here or post a URL to your patch file and we will get them into the next point release of ImageMagick.
Re: Setting caption font properties using MagickWand API
The patch got incredibly messy because there are some chars that my editor seems to be stripping. Nano shows them as ^L. This is the first time I checking to code in the ImageMagick side so this might not be the optimal way:
But here is magick-property.c:
I'll try to figure out a clean way to create the patch (all thou changes in magick-property.h are not hard to add).
But here is magick-property.c:
Code: Select all
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% M a g i c k S e t F o n t %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% MagickSetFont() sets the font for the MagickWand.
%
% The format of the MagickSetFont method is:
%
% MagickBooleanType MagickSetFont(MagickWand *wand, const char *font)
%
% A description of each parameter follows:
%
% o wand: The magick wand.
%
% o font: the font
%
*/
WandExport MagickBooleanType MagickSetFont(MagickWand *wand, const char *font)
{
if ((font == (const char *) NULL) || (*font == '\0'))
return(MagickFalse);
assert(wand != (MagickWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
(void) CloneString(&wand->image_info->font,font);
return(MagickTrue);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% M a g i c k G e t F o n t %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% MagickGetFont() gets the font from the MagickWand.
%
% The format of the MagickGetFont method is:
%
% char *MagickGetFont(MagickWand *wand)
%
% A description of each parameter follows:
%
% o wand: The magick wand.
%
*/
WandExport char *MagickGetFont(MagickWand *wand)
{
assert(wand != (MagickWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if(wand->image_info->font != (char *) NULL)
return(AcquireString(wand->image_info->font));
return((char *) NULL);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% M a g i c k S e t F o n t S i z e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% MagickSetFontSize() sets the font size for the MagickWand.
%
% The format of the MagickSetFontSize method is:
%
% MagickBooleanType MagickSetFontSize(MagickWand *wand, const double pointsize)
%
% A description of each parameter follows:
%
% o wand: The magick wand.
%
% o pointsize: the size of the font
%
*/
WandExport MagickBooleanType MagickSetFontSize(MagickWand *wand, const double pointsize)
{
assert(wand != (MagickWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
wand->image_info->pointsize = pointsize;
return(MagickTrue);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% M a g i c k G e t F o n t S i z e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% MagickGetFontSize() gets the font size from the MagickWand.
%
% The format of the MagickGetFontSize method is:
%
% double MagickGetFontSize(MagickWand *wand)
%
% A description of each parameter follows:
%
% o wand: The magick wand.
%
*/
WandExport double MagickGetFontSize(MagickWand *wand)
{
assert(wand != (MagickWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(wand->image_info->pointsize);
}
Mikko Koppanen
My blog: http://valokuva.org
My blog: http://valokuva.org
Re: Setting caption font properties using MagickWand API
We put your patches in ImageMagick 6.3.6-4 Beta. The updates will be available in a day or two.
Re: Setting caption font properties using MagickWand API
Thanks!
I was wondering should there be other accessors also? And I couldn't find anything to set polaroid properties trough magickwand (polaroid could use some space for a caption in the bottom side).
I was wondering should there be other accessors also? And I couldn't find anything to set polaroid properties trough magickwand (polaroid could use some space for a caption in the bottom side).
Mikko Koppanen
My blog: http://valokuva.org
My blog: http://valokuva.org
Re: Setting caption font properties using MagickWand API
I found the MagickSetBackgroundColor accessor. Next thing might be font color? (I think then all is done for caption:)
Mikko Koppanen
My blog: http://valokuva.org
My blog: http://valokuva.org