Can anyone help me out to convert these command line codes to MagickWand API?
convert input.jpg -format "%[fx:mean]" info:
convert xc: -format "%[fx:mean]" info:
convert input.jpg -function polynomial "10,-5.0" output.jpg
Thank you in advance,
Kamila
Command Line equivalent for MagickWand API
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Command Line equivalent for MagickWand API
I thought the first two would be easy but I'm having trouble replicating the values that I get from the command line.
If I sort it out I'll post them later.
Here's a C function which does the third command.
If I sort it out I'll post them later.
Here's a C function which does the third command.
Code: Select all
// convert input.jpg -function polynomial "10,-5.0" output.jpg
// Remove this next line if you're using Linux
#include <windows.h>
#include <wand/magick_wand.h>
void test_wand(LPTSTR lpCmdLine)
{
MagickWand *mw = NULL;
double args[2] = {10,-5.0};
MagickWandGenesis();
mw = NewMagickWand();
MagickReadImage(mw,"input.jpg");
MagickFunctionImage(mw,PolynomialFunction,2,args);
MagickWriteImage(mw,"output.jpg");
DestroyMagickWand(mw);
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: Command Line equivalent for MagickWand API
Thank you for your help on the 3rd one. Looking forward to first & second...
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Command Line equivalent for MagickWand API
Here's the code to match the first command. For the second command just change "input.jpg" to "xc:" and recompile.
Code: Select all
#include <windows.h>
#include <wand/magick_wand.h>
void test_wand(LPTSTR lpCmdLine)
{
MagickWand *mw = NULL;
double mean,sd;
char info[128];
MagickWandGenesis();
// convert input.jpg -format "%[fx:mean]" info:
mw = NewMagickWand();
MagickReadImage(mw,"input.jpg");
MagickGetImageChannelMean(mw,RedChannel,&mean,&sd);
// [fx:mean] prints the normalized mean of the Red channel
// But the MagickWand function returns the unnormalized mean
// so divide by 65535 to match what the convert command prints
sprintf(info,"logo: mean = %12g",mean/65535);
MessageBox(NULL,info,"",MB_OK);
DestroyMagickWand(mw);
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: Command Line equivalent for MagickWand API
el_supremo, you're a lifesaver! thank you so much for your help!
I have one more command line that I can't figure out to convert to API.
I'd really appriciate if you can take a look at this too.
convert img1.jpg img2.jpg -compose vivid_light -composite output.jpg
Thanks in advance!
I have one more command line that I can't figure out to convert to API.
I'd really appriciate if you can take a look at this too.
convert img1.jpg img2.jpg -compose vivid_light -composite output.jpg
Thanks in advance!
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Command Line equivalent for MagickWand API
You just read the two images and then do:
where mw is the wand for img1.jpg and mw2 is the wand for img2.jpg.
For more examples of MagickWand see the link in my signature.
Pete
Code: Select all
MagickCompositeImage(mw,mw1,VividLightCompositeOp,0,0);
For more examples of MagickWand see the link in my signature.
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.
Re: Command Line equivalent for MagickWand API
I'll check out your examples for sure...
Thanks a lot again!
Thanks a lot again!