
hi,
I am using Jmagick library in my swing application I want to add an image (say logo) on an existing image. can any one explains how ?
Thanks.

hi,
In Jmagick you can use the following code to add image on an existing image
You can give one of the following value according to opacity you want to give your image
CompositeOperator.OverlayCompositeOp
CompositeOperator.SoftLightCompositeOp
CompositeOperator.HardLightCompositeOp
For providing the custom opacity you can constitute the following method along with these above value
transparentImage(PixelPacket.queryColorDatabase("ColorName"),int opacity value (0-65535)); Here 0 specifies the fully opacity and 65535 specifies the fully opaque.
Following code may help you to understand how to use these methods and values in to adding an image to an existing image.
ImageInfo ii = new ImageInfo("abc.jpg");
MagickImage mi = new MagickImage(ii);
ImageInfo logoImage = new ImageInfo("logo.jpg");
logoImage.setSize("120 * 60");
MagickImage logo = new MagickImage(logoImage);
logo.transparentImage(PixelPacket.queryColorDatabase("white"),0);
mi.compositeImage(CompositeOperator.OverlayCompositeOp, logo, 120, 80);
mi.setFileName("newImage.jpg");
mi.writeImage(ii);
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.