Delete a specific page from tiff file


#1

Hello,


I there a way to delete a specific page from a tiff file using Aspose?

Thanks in advanced



#2

Hi there,


Thanks for your inquiry. You can easily remove desired frame from multi-page TIFF. please check following code snippet for the purpose. Please note you can’t remove frame for single page TIFF and to remove first frame of image have to change active frame to second frame.

TiffImage multiImage = (TiffImage)Image.Load(“input.tif”);

if (mulitImage.Frames.Length > 1)
{
//To remove first frame of Image
//multiImage.ActiveFrame = convertedImage.Frames[1];
ultiImage.RemoveFrame(2);
multiImage.Save(“output.tif”);
}

Best Regards,

#3

Hi,


The thing is I want to save to stream and use that stream to maybe delete again. Is this possible?

I tried as in the below code snippet but at the second run i’m having a stream.length = 0
MemoryStream retVal = new MemoryStream();
TiffImage tiff = (TiffImage)Aspose.Imaging.Image.Load(fileStream);

if (tiff.Frames.Length > 1)
{

if (frameIndex == 0)
{
tiff.ActiveFrame = tiff.Frames[frameIndex + 1];
}
tiff.RemoveFrame(frameIndex);
tiff.Save(retVal);
}


Any idea?!! Thanks in advanced 



#4
Hi there,

Thanks for your inquiry. Please reset the stream to beginning while returning stream. Hopefully it will resolve the issue.

retVal.Seek(0, SeekOrigin.Begin);
return retVal;

Best Regards,