Hi Team,
The below variable pagesCount should have value a 6 but it coming 7.
NOPHI_6.7z (312.8 KB)
using (TiffImage MultiFrameImage = (TiffImage)Image.Load("NOPHI_6.tif"))
{
pagesCount = MultiFrameImage.Frames.Length;
}
Hi Team,
The below variable pagesCount should have value a 6 but it coming 7.
NOPHI_6.7z (312.8 KB)
using (TiffImage MultiFrameImage = (TiffImage)Image.Load("NOPHI_6.tif"))
{
pagesCount = MultiFrameImage.Frames.Length;
}
Hi, @Gpatil !
Thank you for being so interested in Aspose.Imaging.
Considering your case it turns out the following:
The following code could help you to understand this issue and work around such a case.
int pagesCount, frameLength;
int scanPageCount = 0;
using (TiffImage MultiFrameImage = (TiffImage)Image.Load("NOPHI_6.tif"))
{
// Take the real page count this way,
pagesCount = MultiFrameImage.PageCount;
// or this way
final TiffFrame[] frames = MultiFrameImage.Frames;
frameLength = frames.Length;
// TIFF specific processing...
// if the first page has the PageNumber tag, we count only pages containing this tag.
TiffDataType tagWithPageNumbers = frames[0].FrameOptions.GetTagByType(TiffTags.PageNumber);
if (tagByType != null)
{
int[] value = (int[]) tagByType.Value;
// second value is the total count of scanned pages, the first one is the index starting from zero
scanPageCount = value[1];
}
if (scanPageCount != 0)
{
// this code will export only pages with the PageNumber tag
foreach (TiffFrame frame in frames)
{
TiffDataType pageNumber = frame.FrameOptions.GetTagByType(TiffTags.PageNumber);
if (pageNumber == null)
{
continue;
}
int[] pageNumbers = (int[]) pageNumber.Value;
frame.Save("page_" + pageNumbers[0] + ".jpg", new JpegOptions());
}
}
else
{
// this code will export all pages really stored in TIFF
int i = 0;
foreach (TiffFrame frame in frames)
{
frame.Save("page_" + i + ".jpg", new JpegOptions());
i++;
}
}
}
Console.WriteLine("pagesCount = {0}", pagesCount);
Console.WriteLine("frameLength = {0}", frameLength);
Console.WriteLine("scanPageCount = {0}", scanPageCount);