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?
Basic help to get mestarted
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Basic help to get mestarted
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
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();
}
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
See my message in this topic for a link to a zip of all the files.
Re: Basic help to get mestarted
Very nice examples
This should get me started
I do miss the man pages
Thanks
This should get me started
I do miss the man pages
Thanks
Re: Basic help to get mestarted
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
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
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Basic help to get mestarted
Yes, there's a documentation error in both MagickEvaluateImageChannel and MagickFunctionImageChannel. Neither function describes that it requires a Channel argument.
Pete
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
See my message in this topic for a link to a zip of all the files.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Basic help to get mestarted
Report it as a bug if the documentation is wrong. Better yet provide replacement text that can be just copy and pasted into place.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/