Append TIFF Creates Black Pages

Discussions about image processing and document imaging.
Post Reply
Vjeran
Posts: 1
Joined: Tue Mar 12, 2024 3:48 pm

Append TIFF Creates Black Pages

Post by Vjeran » Tue Mar 12, 2024 4:01 pm

Hi,
We have upgraded one of our software applications to the new version of your product and are experiencing severe problems when appending pages from TIFF images into a multipage TIFF image.
When our software uses your product to append pages from one TIFF image to another, the first page (created when the new image is created in memory with TiffCreateMultiPageFromGdPictureImage) is OK, but all the subsequent pages are completely black.
Our version of the GdPicture (licensed) is: 14.2.65.0
Our application is built against .NET Framework 4.7.1, Any CPU, Prefer 32-bit.
The source image file formats affected by this problem are JPEG (in TIFF), (Grayscale or B&W), ZIP (in TIFF), Grayscale, Macintosh PackBits, Grayscale TIFF, and uncompressed TIFF images.
If the source images are TIFFs with LZW, Grayscale, all the pages, including the first one will be black in the resulting image file.
When a file with another compression is amongst the source files, the pages from that file are added into the resulting file in a correct way but others are black.
If the source image is duplicated by creating a new image in memory (with TiffCreateMultiPageFromGdPictureImage) and appending all source pages into the new image (with TiffSelectPage & TiffAppendPageFromGdPictureImage), the problem will also appear.
However, if the source image is just saved under another name (TiffCreateMultiPageFromFile then TiffSaveMultiPageToFile on using same handle) or if just the first page (created when the new image is created in memory with TiffCreateMultiPageFromGdPictureImage) is saved (with TiffSaveMultiPageToFile) under a different name, the problem will NOT appear.
If the source images are single page TIFFs, the problem will still appear.
If the source images were opened and saved within another software beforehand, such as IrfanView, the problem will still appear.
If there is just one source file and one of its pages is appended to the same file (TiffSelectPage any page and TiffAppendPageFromGdPictureImage to the same handle, then TiffSaveMultiPageToFile on the same handle), without ever creating a new image in memory, the appended page will still be black.
The short code to reproduce the problems:

Code: Select all

	    var multiPageImageOut = 0;
            var newFileName = Path.ChangeExtension(selectedFilename, ".tmp");
            var tiffCompression = TiffCompression.TiffCompressionUnknown;

            using (var gdPictureImaging = new GdPictureImaging())
            {
                foreach (var filename in fileNames)
                {
                    var multiPageImageIn = gdPictureImaging.TiffCreateMultiPageFromFile(filename, true);
                    if (tiffCompression == TiffCompression.TiffCompressionUnknown)
                    {
                        tiffCompression = gdPictureImaging.GetTiffCompression(multiPageImageIn);
                    }

                    var numberOfPages = gdPictureImaging.GetPageCount(multiPageImageIn);
                    var status = gdPictureImaging.TiffSelectPage(multiPageImageIn, 1);
 
                    if (multiPageImageOut == 0)
                    {
                        multiPageImageOut = gdPictureImaging.TiffCreateMultiPageFromGdPictureImage(multiPageImageIn);
                    }
                    else
                    {
                        status = gdPictureImaging.TiffSelectPage(multiPageImageIn, 1);
                        gdPictureImaging.TiffAppendPageFromGdPictureImage(multiPageImageOut, multiPageImageIn);
                    }

                    for (var i = 2; i <= numberOfPages; i++)
                    {
                        status = gdPictureImaging.TiffSelectPage(multiPageImageIn, i);
                        gdPictureImaging.TiffAppendPageFromGdPictureImage(multiPageImageOut, multiPageImageIn);
                    }

                    gdPictureImaging.ReleaseGdPictureImage(multiPageImageIn);
                }

                gdPictureImaging.TiffSaveMultiPageToFile(multiPageImageOut, newFileName, tiffCompression);
                gdPictureImaging.ReleaseGdPictureImage(multiPageImageOut);
            }

            File.Move(newFileName, selectedFilename);
            return selectedFilename;

Hugo
Posts: 227
Joined: Tue Dec 18, 2018 10:09 am

Re: Append TIFF Creates Black Pages

Post by Hugo » Wed Mar 13, 2024 5:02 pm

Hi there,

Thank you for your feedback here.

I have responded to your ticket you submitted us. For this specific issue, this likely relates to a change within the TIFF handling library internally which we shipped with V14.2.64. I would recommend using V14.2.63 for now to bypass this if you are still experiencing the issue.

If this is relating to specific images then please provide these so we may address them and fix it for our next minor releases. Currently, our devs have fixed 2 of these bugs with files which may solve this for you aswell. This fix will be shipped in V14.2.66 so I'd recommend trying this aswell once it is released.

Regards,
Hugo Cudd
Technical Support

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests