Pdf tp tiff color depth problem

Hi,


While converting pdf to tiff , there is no option to change depth to 24.

only
Default = 0,
Format8bpp = 1,
Format4bpp = 2,
Format1bpp = 3


i need 24 as depth?

Thanks in advance.

Hi Aravind,

I have observed your requirements and like to share that any image saved in the format tiff with a color depth of 24 bit can be as follows:

TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.TiffJpegRgb)
image.Save(destFile, tiffOptions);

Can you please share your working sample code that what you are trying to achieve so that I may help you further.

Many Thanks,

Hi,

NOTE:"PDF to TIFF Conversion "

I have tried with code but still we didn’t get the exact file (We need file size to reduced ) ,also attached the files that processed and file we expecting.



/Our code
var pdfConverter = new PdfConverter();
pdfConverter.BindPdf(inputFilePath);
if (argModel.dpiToAdjust != null)
{
var resolution = new Resolution(argModel.dpiToAdjust.Value);
pdfConverter.Resolution = resolution;

}

pdfConverter.DoConvert();
var height = 200;
var width = 200;
pdfConverter.SaveAsTIFF(outputFilePath, width, height, tiffSettings);

//Your code

using (var multiImage = (TiffImage)Image.Load(outputFilePath))
{
TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.TiffJpegRgb);
if (argModel.dpiToAdjust != null)
{
tiffOptions.Xresolution = new TiffRational(Convert.ToUInt32(argModel.dpiToAdjust.Value));
tiffOptions.Yresolution = new TiffRational(Convert.ToUInt32(argModel.dpiToAdjust.Value));
}

multiImage.Save(@“C:\IDOX\Conversion\PDF\test.tiff”, tiffOptions);
}
we the file excatly same the file we attached to you named "FileWeExpectingLikeThis.tif"

Thanks in advance

Hi Aravind,

I have observed the generated output and have consulted our product team in this regard as well. Moreover, I am unable to use the sample code shared by you as well. I suggest you to please try using following TiffOptions in your application and observe the results. If there is still an issue then please share the working sample project with us for further investigation on our end.

TiffOptions options = new TiffOptions(TiffExpectedFormat.TiffJpegYCbCr);

Many Thanks,

Hi,


I have tried this code and got the optimal result,but while validating the file via JHOVE (Open Source Image Validator - Tools - Open Preservation Foundation)

Its say the result :Not well formed

While validating in JHOVE
Please tick the TIFF-hul from

EDIT->Select Module->TIFF-hul

Also attached the files

CODE:

var pdfDocument = new global::Aspose.Pdf.Document(inputFilePath);
var tiffSettings = new TiffSettings
{
Compression = CompressionType.LZW,
Depth = ColorDepth.Default,
SkipBlankPages = false
};

var resolution = new Resolution(96);
var ms = new MemoryStream();
var tiffDevice = new TiffDevice(resolution, tiffSettings);
tiffDevice.Process(pdfDocument, ms);
ms.Position = 0;
using (var image = (RasterImage)Image.Load(ms))
{
using (var tiffStream = new MemoryStream())
{
var res = 96;
var tiffOptions = new TiffOptions(TiffExpectedFormat.TiffJpegYCbCr)
{
ResolutionSettings = new ResolutionSetting(res, res)
};
image.Save(tiffStream, tiffOptions);
tiffStream.WriteTo(new FileStream(outputFilePath, FileMode.Create));
tiffStream.Position = 0;
}
}




Hi Aravind,

I have observed the information shared by you and have created an issue with ID IMAGINGNET-2312 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed.

We are sorry for your inconvenience,

Hi,

The issue is the YCbCrSubsampling tag, which should be 2 SHORT (16-bit unsigned) values, with 2 BYTE or LONG values also being valid.

In this image this tag has 2 SHORT (16-bit signed) values, which isn’t valid.

In addition, the ReferenceBlackWhite tag, which is required for a class Y TIFF, is missing (this is treated as a warning by Trapeze, not an error).

we are working to a very tight schedule , how much time will it take to resolve this issue?

Hi Aravind,

Thank you for sharing the additional information. I have update the information in associated ticket. I also like to add here that issue has just been logged and our product will schedule and log the issue as soon as possible on its due turn. We will share the good news with you when it will be shared by our product team.

Many Thanks,

@ARAVINDDSRC,

Our product team has investigated the issue using latest Aspose.Imaging for .NET 17.11 and Aspose.Pdf on our end. We have tried to convert Pdf to Tiff using the following code which is very similar to one you have shared earlier.

/// <summary>
/// Saves Pdf to Tiff with Jpeg compression and YCbCr color format.
/// </summary>        
private void SavePdfToTiffJpegYCbCr(string pdfPath, string tiffPath)
{
	string licensePath = @"c:\aspose.imaging.net\testdata\license\Aspose.Total.lic";

	Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
	pdfLicense.SetLicense(licensePath);

	Aspose.Imaging.License imagingLicense = new Aspose.Imaging.License();
	imagingLicense.SetLicense(licensePath);

	Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(pdfPath);
	Aspose.Pdf.Devices.TiffSettings tiffSettings = new Aspose.Pdf.Devices.TiffSettings
	{
		Compression = Aspose.Pdf.Devices.CompressionType.LZW,
		Depth = Aspose.Pdf.Devices.ColorDepth.Default,
		SkipBlankPages = false
	};

	Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(96);
	Aspose.Pdf.Devices.TiffDevice tiffDevice = new Aspose.Pdf.Devices.TiffDevice(resolution, tiffSettings);

	using (Stream tiffStream = new MemoryStream())
	{
		tiffDevice.Process(pdfDocument, tiffStream);

		tiffStream.Seek(0, SeekOrigin.Begin);
		using (Image image = Image.Load(tiffStream))
		{
			Aspose.Imaging.ImageOptions.TiffOptions tiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.TiffJpegYCbCr);
			tiffOptions.ResolutionSettings = new ResolutionSetting(96.0, 96.0);

			using (Stream tiffJpegYCbCrStream = new FileStream(tiffPath, FileMode.Create))
			{
				image.Save(tiffJpegYCbCrStream, tiffOptions);
			}
		}
	}
}

We have got a well-formed valid output Tiff image as you can see from attached jhove_stat.txt. Can you please try to use the above code to get valid Tiff with Jpeg compression and YCbCr color format:

SavePdfToTiffJpegYCbCr("6031.pdf", "6031_YCbCr Out.tiff");

Then check it for correctness with JHove and provide your feedback please. At the moment we are unable to reproduce the bug on our side.

jhove_stat.txt.zip (1.9 KB)
6031_YCbCr Out.tiff.zip (2.7 MB)

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.