Code: Select all
convert cnbc_r.jpg \
'(' cnbc_i.jpg +transparent '#0A0B0D' -alpha extract ')'\
'(' cnbc_p.jpg -rotate -33.75 +repage -gravity center -crop 600x437+0+0 +repage ')'\
'(' -clone 0 -clone 2 -compose softlight -composite ')'\
-delete 0,2 +swap -compose over -alpha off -compose copy_opacity -composite\
'(' +clone -alpha extract -write mpr:alpha -blur 0x4 -shade 130x30 mpr:alpha -alpha off\
-compose copy_opacity -composite -alpha on -alpha background -alpha deactivate\
-auto-level -function polynomial 3.5,-5.05,2.05,0.25 -sigmoidal-contrast 0x50% -alpha on ')'\
-compose over -compose Hardlight -composite\
'(' -clone 0 -background black -shadow 25x2+0+0 -channel A -level 0,50% +channel ')'\
+swap +repage -gravity center -compose over -composite cnbc_1.jpg
cnbc_i.jpg
https://drive.google.com/file/d/0B-HZjm ... sp=sharing
cnbc_p.jpg
https://drive.google.com/file/d/0B-HZjm ... sp=sharing
cnbc_r.jpg
https://drive.google.com/file/d/0B-HZjm ... sp=sharing
cnbc_1.jpg
https://drive.google.com/file/d/0B-HZjm ... sp=sharing
Code: Select all
#include "MagickWand/studio.h"
#include "MagickWand/MagickWand.h"
void test() {
/* convert cnbc_r.jpg \
'(' cnbc_i.jpg +transparent '#0A0B0D' -alpha extract ')'\
'(' cnbc_p.jpg -rotate -33.75 +repage -gravity center -crop 600x437+0+0 +repage ')'\
'(' -clone 0 -clone 2 -compose softlight -composite ')'\
-delete 0,2 +swap -compose over -alpha off -compose copy_opacity -composite\
'(' +clone -alpha extract -write mpr:alpha -blur 0x4 -shade 130x30 mpr:alpha -alpha off\
-compose copy_opacity -composite -alpha on -alpha background -alpha deactivate\
-auto-level -function polynomial 3.5,-5.05,2.05,0.25 -sigmoidal-contrast 0x50% -alpha on ')'\
-compose over -compose Hardlight -composite\
'(' -clone 0 -background black -shadow 25x2+0+0 -channel A -level 0,50% +channel ')'\
+swap +repage -gravity center -compose over -composite cnbc_1.jpg */
MagickWand * wand1, * wand2, * wand3, * wand4, * wandc0, * wandc1, * wandc2, * wandc3, * wandc4, * wandc5;
PixelWand *PW1, * PW2, * pwand;
PW1 = NewPixelWand();
PW2 = NewPixelWand();
pwand = NewPixelWand();
wand1 = NewMagickWand();
wand2 = NewMagickWand();
wand3 = NewMagickWand();
MagickReadImage(wand1, "cnbc_r.jpg");
MagickReadImage(wand2, "cnbc_i.jpg");
MagickReadImage(wand3, "cnbc_p.jpg");
// (' cnbc_i.jpg +transparent '#0A0B0D' -alpha extract ')'
PixelSetColor(PW1,"#0A0B0D");
MagickTransparentPaintImage(wand2, PW1, 1.0, 0, MagickFalse);
MagickSetImageAlphaChannel(wand2, ExtractAlphaChannel);
// '(' cnbc_p.jpg -rotate -33.75 +repage -gravity center -crop 600x437+0+0 +repage ')'
MagickRotateImage(wand3,pwand,-33.75);
MagickSetImageGravity(wand3, CenterGravity);
MagickCropImage(wand3, 600, 437, 0, 0);
MagickResetImagePage(wand3,"600x437+0+0");
// '(' -clone 0 -clone 2 -compose softlight -composite ')'
wandc0 = CloneMagickWand(wand1);
wandc1 = CloneMagickWand(wand3);
wandc2 = CloneMagickWand(wand1);
wandc5 = CloneMagickWand(wand1);
MagickCompositeImage(wandc0, wandc1, SoftLightCompositeOp,MagickFalse, 0, 0);
// -delete 0,2 +swap -compose over -alpha off -compose copy_opacity -composite
MagickCompositeImage(wand1, wand2, OverCompositeOp,MagickFalse, 0, 0);
MagickCompositeImage(wand1, wand3, OverCompositeOp,MagickFalse, 0, 0);
MagickCompositeImage(wand1, wandc0, OverCompositeOp,MagickFalse, 0, 0);
MagickSetImageAlphaChannel(wand1, OffAlphaChannel);
// '(' +clone -alpha extract -write mpr:alpha -blur 0x4 -shade 130x30 mpr:alpha -alpha off
// -compose copy_opacity -composite -alpha on -alpha background -alpha deactivate
// -auto-level -function polynomial 3.5,-5.05,2.05,0.25 -sigmoidal-contrast 0x50% -alpha on ')'
wandc3 = CloneMagickWand(wand1);
MagickSetImageAlphaChannel(wandc3, ExtractAlphaChannel);
wandc4 = CloneMagickWand(wandc3);
MagickBlurImage(wandc4, 4, 0);
MagickShadeImage(wandc4, MagickTrue, 130, 130);
MagickSetImageAlphaChannel(wandc3, OffAlphaChannel);
MagickCompositeImage(wandc3, wandc4, 0,MagickFalse, 0, 0);
MagickSetImageAlphaChannel(wandc3, OnAlphaChannel);
MagickSetImageAlphaChannel(wandc3, BackgroundAlphaChannel);
MagickSetImageAlphaChannel(wandc3, DeactivateAlphaChannel);
MagickAutoLevelImage(wandc3);
const double arguments[4] = {3.5,-5.05,2.05,0.25};
MagickFunctionImage(wandc3, PolynomialFunction, 4, arguments);
MagickSigmoidalContrastImage(wandc3, MagickTrue, 50.0, 0.0);
MagickSetImageAlphaChannel(wandc3, OnAlphaChannel);
// -compose over -compose Hardlight -composite
MagickCompositeImage(wand1, wand2, OverCompositeOp,MagickFalse, 0, 0);
MagickCompositeImage(wand1, wand3, OverCompositeOp,MagickFalse, 0, 0);
MagickCompositeImage(wand1, wandc0, OverCompositeOp,MagickFalse, 0, 0);
MagickCompositeImage(wand1, wandc3, OverCompositeOp,MagickFalse, 0, 0);
//'(' -clone 0 -background black -shadow 25x2+0+0 -channel A -level 0,50% +channel ')'
PixelSetColor(PW2,"#000000");
MagickSetImageBackgroundColor(wandc5, PW2);
MagickShadowImage(wandc5, 0, 0, 25, 25);
MagickSetImageChannelMask(wandc5, AlphaChannel);
MagickLevelImage(wandc5, QuantumRange/2, 1.0, 0);
// +swap +repage -gravity center -compose over -composite ./cnbc__1.jpg
MagickResetImagePage(wand1,"600x437+0+0");
MagickSetImageGravity(wand1, CenterGravity);
MagickCompositeImage(wand1, wandc5, OverCompositeOp,MagickTrue, 0, 0);
MagickWriteImage(wand1,"finalCnbc.jpg");
DestroyMagickWand(wand1);
DestroyMagickWand(wand2);
DestroyMagickWand(wand3);
DestroyMagickWand(wandc0);
DestroyMagickWand(wandc1);
DestroyMagickWand(wandc2);
DestroyMagickWand(wandc3);
DestroyMagickWand(wandc4);
DestroyMagickWand(wandc5);
DestroyPixelWand(PW1);
DestroyPixelWand(PW2);
DestroyPixelWand(pwand);
MagickWandTerminus();
}