Removing Image Soft Masks

Q: We are having some trouble with adding images to a PDF page. A code snippet is attached below.

The images are drawn exactly as we would expect visually. The problem is that we appear to be getting Soft Masks added to each of the images inside the XObject. This is causing problems downstream with the rest of our workflow. Are there changes we can make to prevent or remove the soft masks from the image? I noticed Set and Get methods in the object model, but nothing to clear an existing mask. I also checked the forums and could not find anything relating to removing the masks.

ElementBuilder bld = new ElementBuilder();
Image img = Image.Create(temp, bmp);
Element element = bld.CreateImage(img, new Matrix2D(w, 0, 0, h, x, y));

A: The Soft Masks can be removed after the image has been created with the following line:
img.GetSDFObj().Erase(“SMask”);

This should still work even if the image does not have a soft mask. So your code would look like the following:

ElementBuilder bld = new ElementBuilder();
Image img = Image.Create(temp, bmp);
img.GetSDFObj().Erase(“SMask”);
Element element = bld.CreateImage(img, new Matrix2D(w, 0, 0, h, x, y));