How do you add a transparent image watermark to an image?

Hello, @msdos41 ,
Let me process your request and the attached sources. You will be answered shortly!

@Denis.Sitko Thank you!

Also I tried the bw watermark, and just use the save method without options as you advised before.
But it will also get the error “Attempted to divide by zero.” which confused me a lot.

@djsomers
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): IMAGINGNET-6428

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

As a workaround I recommend using the next save options:

  1. Using original save options with losing the watermark colors but keeping low output size:
    image.Save(savePath);

  2. Using the next save options (this one produces output without errors, but increases size and keeps colors of watermark)

     var options = new Aspose.Imaging.ImageOptions.TiffOptions(TiffExpectedFormat.TiffLzwRgb)
     {
         RowsPerStrip = 128,
     };
    

As for the large TIFF file the options below seem to work. But it takes much time to save due to very large size. Using the option 2 above speeds up processing, but increases the size. Option 1 will output totally BW output (seems to me the best option due to time/performance).

ushort bpp = 8;
var options = new TiffOptions(TiffExpectedFormat.Default)
{
    BitsPerSample = new ushort[] { bpp },
    Compression = TiffCompressions.Lzw,
    Photometric = TiffPhotometrics.Palette,
    Palette = ColorPaletteHelper.GetCloseImagePalette(image, 1  <<  bpp),
};

As concerns processing images with large dimensions, it is important to use LoadOptions.BufferSizeHint. It also takes longer to process such images.

@Denis.Sitko

You did not get the error “Attempted to divide by zero.” when dealing with test_1.tif ?

@msdos41 , as I said before I managed to reproduce error for tiff1. You can see the link to the ticket. This error does not occur for the second tiff.