First page of the Tif corrupt while convert / Extract to PDF / Tif using Aspose Imaging

Using Aspose imaging DLL we can successfully convert LZW compression TIF file to normal TIF file, but the first page of the TIF got corrupted, and the rest of the TIF page has been converted properly. I have attached a screenshot of the corrupted page, as well as the source code.Capture.PNG (48.5 KB)

code snippet 1:

using Aspose.Imaging;
using Aspose.Imaging.FileFormats.Tiff;
using Aspose.Imaging.ImageOptions;
using Aspose.Imaging.Sources;
using Aspose.Imaging.FileFormats.Tiff.Enums;
using System.Web.Mvc;

public void ConvertTif(){
string imageFilePath = @“D:\test.tif”;
string outputFilePath = @“D:\testimg.tif”;
TiffImage source = (TiffImage)Image.Load(imageFilePath);
TiffOptions options = new TiffOptions(0);
options.Source = new FileCreateSource(outputFilePath, false);
using (TiffImage result = (TiffImage)Image.Create(options, source.Width, source.Height))
{
foreach (TiffFrame frame in source.Frames)
{
TiffFrame copiedFrame = TiffFrame.CopyFrame(frame);
copiedFrame.FrameOptions.Compression = TiffCompressions.CcittFax3;
copiedFrame.FrameOptions.BitsPerSample = new ushort[] { 1 };
copiedFrame.FrameOptions.Photometric = TiffPhotometrics.MinIsBlack;
result.AddFrame(copiedFrame);
}
if (result.Frames.Length > 1)
{
result.ActiveFrame = result.Frames[1];
result.RemoveFrame(0);
}
result.Save();
}
}

Code snippet 2:

using Aspose.Imaging;
using Aspose.Imaging.FileFormats.Tiff;
using Aspose.Imaging.ImageOptions;
using Aspose.Imaging.Sources;
using Aspose.Imaging.FileFormats.Tiff.Enums;
using System.Web.Mvc;

public void convertTif(){
string imageFilePath = @“D:\test.tif”;
string outputFilePath = @“D:\S.tif”;
Image image = Image.Load(imageFilePath);
TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default);
outputSettings.BitsPerSample = new ushort[] { 4 };
outputSettings.Compression = TiffCompressions.Lzw;
outputSettings.Photometric = TiffPhotometrics.Palette;
outputSettings.Palette = ColorPaletteHelper.Create4BitGrayscale(false);
image.Save(outputFilePath, outputSettings);
}

@eNoahAdmin Please provide the source TIF file so we could test it with the sample code.

Hi Alexey,

Due to the nature of the image, we are not able to provide you the file. We are unable to recreate this issue with our own test image. We have received several of these with the similar format. The images comes to us via means of fax. I can provide the TIF contents for the first 2 IFD headers. See below.

---- File ----
File Type : TIFF
File Type Extension : tif
MIME Type : image/tiff
Exif Byte Order : Little-endian (Intel, II)
---- IFD0 ----
Image Width : 1700
Image Height : 2200
Bits Per Sample : 1
Compression : LZW
Photometric Interpretation : WhiteIsZero
Fill Order : Unknown (0)
Image Description :
Strip Offsets : (Binary data 326 bytes, use -b option to extract)
Rows Per Strip : 38
Strip Byte Counts : (Binary data 251 bytes, use -b option to extract)
X Resolution : 200
Y Resolution : 200
Resolution Unit : inches
Software : TIFF.DLL from Black Ice Software, LLC.Version 12.97
Modify Date : 2022:07:15 16:58:21
Artist :
Predictor : Horizontal differencing
---- IFD1 ----
Subfile Type : Full-resolution image
Image Width : 1700
Image Height : 2200
Bits Per Sample : 1
Compression : T6/Group 4 Fax
Photometric Interpretation : WhiteIsZero
Fill Order : Normal
Strip Offsets : 45194
Orientation : Horizontal (normal)
Samples Per Pixel : 1
Rows Per Strip : 2200
Strip Byte Counts : 29917
X Resolution : 200
Y Resolution : 200
T6 Options : (none)
Resolution Unit : inches
---- IFD2 ----
Subfile Type : Full-resolution image
Image Width : 1700
Image Height : 2200
Bits Per Sample : 1
Compression : T6/Group 4 Fax
Photometric Interpretation : WhiteIsZero
Fill Order : Normal
Strip Offsets : 75326
Orientation : Horizontal (normal)
Samples Per Pixel : 1
Rows Per Strip : 2200
Strip Byte Counts : 56671
X Resolution : 200
Y Resolution : 200
T6 Options : (none)
Resolution Unit : inches

@eNoahAdmin unfortunately provided headers is not enought for us to reproduce issue or create ticket. We still need file(may be also synthetic, if you can not provide your sample) that we can load to

Please close this item. It is no longer needed.

Thanks,