We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding Watermark to image

Hi,
we are trying to watermark images, no matter what type. in the tests following your Examples, for png it works well, but not for emf files. Image was loaded properly but drawString didn’t worked.
“Exception in thread “main” class com.aspose.imaging.internal.Exceptions.ArgumentNullException: Value cannot be null.
Parameter name: image”

any idea?

here is the code:

    Image tmpImg = Image.load("f_lb37.emf");

    Graphics tmpGr = new Graphics(tmpImg);

    // Creates an instance of Font
    Font font = new Font("Times New Roman", 50, FontStyle.Bold);

    // Create an instance of SolidBrush and set its properties
    SolidBrush brush = new SolidBrush();
    brush.setColor(Color.getGray());
    brush.setOpacity(100);

    // Draw a string using the SolidBrush and Font objects at specific point
    tmpGr.drawString("Watermark TEST", font, brush, new PointF(tmpImg.getWidth()/2, tmpImg.getHeight()/2));

    // Save image
    tmpImg.save("test_watermark.emf");

@tmdolphin

Can you please try using following documentation link to serve the purpose on your end.

thanks for the response…
i did… but got an exception calling drawString as stated in the thread above!

br robert

@tmdolphin

Can you please share your source file so that I may help you further in this regard.

Hello,
thanks for investigating further. Attached please find the image mentioned!figure.7z (3.5 KB)

It’s zipped, as emf file was not allowed to be uploaded :slight_smile:

@tmdolphin

It seems to be an issue while adding the watermark to your image file. A ticket with ID IMAGINGJAVA-7936 has been created to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.