We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Concatenate Multiple TIFF Images

Hi, I’m trying concatenate multiple tiff, with this code, but this method throws an exception format in Image.Load(…). What can I do? Thank you, very much!


string MyDir = @“C:\G3”;
//Create a copy of original image to avoid any alteration
File.Copy(MyDir + “00874076.tif”, MyDir + “008740762.tif”, true);


//Create an instance of TiffImage and load the copied destination image
using (TiffImage image = (TiffImage)Aspose.Imaging.Image.Load(MyDir + “00874076.tif”))
{
//Create an instance of TiffImage and load the source image
using (TiffImage image1 = (TiffImage)Aspose.Imaging.Image.Load(MyDir + “008740762.tif”))
{
// Create an instance of TIffFrame and copy active frame of source image
TiffFrame frame = TiffFrame.CopyFrame(image1.ActiveFrame);
// Add copied frame to destination image
image.AddFrame(frame);
// save the image with changes.
image.Save();

}
}

Hi Yolanda,


Thank you for contacting Aspose support.

We have evaluated your presented scenario against the latest version of Aspose.Imaging for .NET 2.3.0. On Image.Load method we have experienced InvalidCastException with message “Unable to cast object of type ‘Aspose.Imaging.FileFormats.Jpeg.JpegImage’ to type ‘Aspose.Imaging.FileFormats.Tiff.TiffImage’”. Upon further investigation we have found that your shared sample image is actually a JFIF (JPEG File Interchange Format), and therefore cannot be cast into an instance of TiffImage. You can verify this by opening the sample image with notepad, you will find JFIF in the header of the image.

Hope this helps a bit.