Identifying the Blank Documents in the InputStream for Tiff Streams

Hi Team

I am looking out for the method in the aspose.tiff to identify the method which actually identifies the blank Streams or which can read the content from Image and Identify the Content to understand on the Blank Document .

Hi, @veera1208 !
We appreciate your interest in Aspose.Imaging.
Firstly, please let me know what you mean by blank document?
Do you mean the TIFF image filled up by the white/black color? Or something else?
Perhaps this code is fit for you.

/**
How to check that the image is "blank" (it means that it contains only full transparent pixels or is only filled by one color)?
Please, pay attention that this example can work only with raster image!
*/

try (RasterImage img = (RasterImage)Image.load("some-image.tiff"))
{
	BlankTester tester = new BlankTester();
	img.loadPartialArgb32Pixels(img.getBounds(), tester);
	System.out.println("Image is empty? > " + tester.isEmpty());
}

static class BlankTester implements IPartialArgb32PixelLoader
{
	// By default, we suppose that image is empty
	private boolean isEmpty = true;
	private int firstColor;
	private boolean needTakeFirstColor = true;
	private static final int AlphaChannelMask = 0xFF000000;

	public boolean isEmpty()
	{
		return isEmpty;
	}

	@Override
	public void process(Rectangle pixelsRectangle, int[] pixels, Point start, Point end)
	{
		if (!isEmpty) // if we already know that it is not empty, skip the checking
			return;

		for (int pixel : pixels)
		{
			// if pixel is not fully transparent then analyze it
			if ((pixel & AlphaChannelMask) != 0)
			{
				if (needTakeFirstColor)
				{
					firstColor = pixel;
					needTakeFirstColor = false;
				}
				else
				if (pixel != firstColor) // and is not equal to first not transparent pixel
				{
					// we suppose that image is not blank.
					isEmpty = false;
					break;
				}
			}
		}
	}
}