TIF image fails to convert to PNG (without giving an error)

Attached a file with a tif that doesn’t give an error/exception, but improperly generates a blank image.

private void convertTIFToPNG(string inputFilePath, string outputFilePath) {
    var doc = new Aspose.Words.Document();
    var builder = new Aspose.Words.DocumentBuilder(doc);
    var shape = builder.InsertImage(inputFilePath);
    shape.ImageData.Save(outputFilePath);
}

libraries:

<PackageReference Include="Aspose.Words" Version="24.1.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.7" />

s-m56-pc-7546-00.zip (10.9 KB)

@kjpual The provided code does not actually convert TIFF to PNG. ImageData.Save method save the image data as is into the specified file, i.e. in your case the inserted TIFF image is saved with PNG extension. To actually convert TIFF to PNG you should use ShapeRenderer. Please see the following code:

private static void ConvertTIFToPNG(string inputFilePath, string outputFilePath)
{
    var doc = new Aspose.Words.Document();
    var builder = new Aspose.Words.DocumentBuilder(doc);
    var shape = builder.InsertImage(inputFilePath);
    shape.GetShapeRenderer().Save(outputFilePath, new ImageSaveOptions(SaveFormat.Png));
}

https://products.aspose.com/words/net/conversion/tiff-to-png/

Can we get some actual support please?

@kjpual There is a mistake in the code provide on this page. Please try using the code I have provide in the previous answer. I have tested on my side and TIFF is properly converted to PNG.

No… it doesn’t work… it gives the same bad output png (attached result file).

This is on amazon linux 2, dotnet 8.

Not only does it give a bad result, it doesn’t raise an error. So there are TWO bugs going on.

badoutput.zip (466 Bytes)

Thousands of other tif files convert fine. But this one (and 10s more) doesn’t, and it also doesn’t open in microsofts image viewer, unlike the other tifs.

@kjpual
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): WORDSNET-26512

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.

The issues you have found earlier (filed as WORDSNET-26512) have been fixed in this Aspose.Words for .NET 24.3 update also available on NuGet.