Thumbnails generated using Aspose.Imaging for .NET not being opened by windows photo viewer

Hi,

I am trying to convert a multiframe tiff image to jpegs using the following code:

   TiffImage tiffImage = (TiffImage) com.aspose.imaging.Image.load(inputStream);
    List<String> jpegFileNames = new ArrayList<String>(tiffImage.getFrames().length);
    String imageFile;
    int pageNumber = 1;
    try
    {
        TiffFrame[] frames = tiffImage.getFrames();
        for (TiffFrame tiffFrame : frames)
        {
          
            imageFile = "C:\\dev\\images\\" + filePrefixName + "XRtempConversionImage_" + pageNumber + ".jpg";
            tiffFrame.save(imageFile, new JpegOptions());
            pageNumber++;
            jpegFileNames.add(imageFile);
        }
    }

I’ve tried on several different multiframe images and it succesfully converts the image. However, the image rendered is unable to be opened by Gimp and Windows Photo Viewer. I am able to succesfully convert multi frame images to png. I would appreciate any assistance.

Edit: Using aspose-imaging 18.6

image.png (2.1 KB)

@drakegens,

I have observed your comments. Can you please try to use Aspose.Imaging 19.1 on your end and if there is still an issue than please share source file along with sample project so that we may further investigate to help you out.

I can validate that the same issue is happening with 19.1. I’ve uploaded the source files with issues and here is my sample code:

public static List<String> convertTiffToJPEG(byte[] tiffByteArray, float compressionQuality, String filePrefixName) throws IOException
{
    ByteArrayInputStream inputStream = new ByteArrayInputStream(tiffByteArray);
    LoadOptions loadOptions = new LoadOptions();
    loadOptions.setDataRecoveryMode(DataRecoveryMode.ConsistentRecover);
    TiffImage tiffImage = (TiffImage) Image.load(inputStream);
    List<String> jpegFileNames = new ArrayList<String>(tiffImage.getFrames().length);
    String imageFile;
    int pageNumber = 1;
    try
    {
        TiffFrame[] frames = tiffImage.getFrames();
        for (TiffFrame tiffFrame : frames)
        {
            JpegOptions jpegOptions = new JpegOptions();
            ResolutionSetting resolutionSetting = new ResolutionSetting(tiffFrame.getHorizontalResolution(), tiffFrame.getVerticalResolution());
            jpegOptions.setResolutionSettings(resolutionSetting);

            imageFile = filePrefixName + "XRtempConversionImage_" + pageNumber + ".jpg";

            tiffFrame.save(imageFile, jpegOptions);

            pageNumber++;
            jpegFileNames.add(imageFile);
        }
    }
    finally
    {
        tiffImage.close();
        }
    }
    return jpegFileNames;
}

@drakegens,

I have observed the issue shared by you and request you to please share the source Tiff file and generated output files along with a working sample code that we may use on our end. The above sample code does not provide information about parameters passed to function. Please share the working example that we may use on our end.

output-1.jpg (179 Bytes)
input1.zip (9.6 MB)

Here’s an example of parameters:

    in8 = new BufferedInputStream(new FileInputStream("src/test/resources/MutliPageTIFFImage.tif"));
    multiPageTiffWithJpegCompression = readImage(in8);

Above is the byte[] passed in. Below are the other parameters.

float compressiongQuality = 0.9
String filePrefixName = “junit_”

I’m having trouble uploading the other problem tiff image as a zip. Is there a size limit on uploading files to these forums?

Thanks

@drakegens,

I have worked with source file and sample code shared by you using Aspose.Imaging and unable to observe any issue. I have also shared my generated result with you for your kind reference. Please check link for generated result file . Can you please share environment details with us so that we may further investigate to help you out.

What sorts of environment details are you looking for?

I’m running jdk 1.6.0_43
Windows 10

@drakegens,

I have tested the sample file on my end using attached sample code The generated JPEG files are getting opened on my end without any issue in Windows Photo viewer and GIMP.

Example.zip (873 Bytes)
out1.zip (4.5 MB)
out2.zip (5.8 MB)

I’ve done some more investigation, and i’ve noticed the issue does not occur with a 64 bit jdk. But it does occur with a 32 bit jdk.

@drakegens,

Thank you for your feedback. Did you try the sample code shared by me on your end.