Page 1 of 1
Basic help to get mestarted
Posted: 2009-02-02T08:34:13-07:00
by rray
I am a long time C programmer but a MagickWand virgin.
Are there man pages for api functions?
"composite -depth 8 -dissolve 15 -gravity center stamp.png source.png destination.png"
Could someone give me a bit of starter code that would accomplish this using MagickWand?
Re: Basic help to get mestarted
Posted: 2009-02-02T14:30:13-07:00
by el_supremo
The code below should do what you want. It uses a method described by Anthony near the end of
this topic
Also see the examples at the URL in my sig.
Pete
Code: Select all
#include <windows.h>
#include <wand/magick_wand.h>
void test_wand(LPTSTR lpCmdLine)
{
MagickWand *magick_wand = NULL,*sig_wand = NULL;
// dimensions of source image
long sw,sh;
// dimensions of stamp (signature) image
long tw,th;
/*
For detailed info about MagickWand functions and their parameters see:
http://studio.imagemagick.org/script/magick-wand.php
*/
MagickWandGenesis();
magick_wand = NewMagickWand();
// Read the image
MagickReadImage(magick_wand,"source.png");
// Get the dimensions of the image
sw = MagickGetImageWidth(magick_wand);
sh = MagickGetImageHeight(magick_wand);
// Strip any profiles, thumbnails etc.
MagickStripImage(magick_wand);
MagickSetImageMatte(magick_wand,1);
// read the stamp (signature) image
sig_wand = NewMagickWand();
MagickReadImage(sig_wand,"stamp.png");
tw = MagickGetImageWidth(sig_wand);
th = MagickGetImageHeight(sig_wand);
MagickStripImage(sig_wand);
// Set the sig file's opacity to 15%
MagickEvaluateImageChannel(sig_wand,AlphaChannel,MultiplyEvaluateOperator,0.15);
// do the Over composite operation and place the stamp image in the centre of the source
MagickCompositeImage(magick_wand,sig_wand,OverCompositeOp,(sw-tw)/2,(sh-th)/2);
// Set the depth to 8
MagickSetImageDepth(magick_wand,8);
// Write the image
MagickWriteImage(magick_wand,"destination.png");
/* Clean up */
if(magick_wand)magick_wand = DestroyMagickWand(magick_wand);
if(sig_wand)sig_wand = DestroyMagickWand(sig_wand);
MagickWandTerminus();
}
Re: Basic help to get mestarted
Posted: 2009-02-03T08:21:26-07:00
by rray
Very nice examples
This should get me started
I do miss the man pages
Thanks
Re: Basic help to get mestarted
Posted: 2009-02-10T14:40:43-07:00
by rray
I think the documentation needs a bit of clarification
Your code has " MagickEvaluateImageChannel(sig_wand,AlphaChannel,MultiplyEvaluateOperator,0.15);"
Four arguments
The documentation at "
http://imagemagick.org/api/magick-image.php" says
MagickBooleanType MagickEvaluateImageChannel(MagickWand *wand, const MagickEvaluateOperator op,const double value)
Three arguments
I would have never figured this out without your code for reference
Richard
Re: Basic help to get mestarted
Posted: 2009-02-10T17:16:23-07:00
by el_supremo
Yes, there's a documentation error in both MagickEvaluateImageChannel and MagickFunctionImageChannel. Neither function describes that it requires a Channel argument.
Pete
Re: Basic help to get mestarted
Posted: 2009-04-29T18:38:37-07:00
by anthony
Report it as a bug if the documentation is wrong. Better yet provide replacement text that can be just copy and pasted into place.