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

Free Support Forum - aspose.com

Unable to cast 'Aspose.Imaging.FileFormats.Jpeg.JpegImage' to type 'Aspose.Imaging.FileFormats.Tiff.TiffImage'


This is to update you that the sample that you shared are not TIFF images. There is only one image [ISIS-6130 A4 600 DUP BW_00028.tif] that is a TIFF. All others are JPG files with incorrect TIFF extension.

var createOptions = new TiffOptions(Default);
var fileStream = new FileStream(outputFilePath, FileMode.Create);
createOptions.Compression = TiffCompressions.None;
createOptions.Source = new StreamSource(fileStream);

using (var output = (TiffImage)Image.Create(createOptions, 100, 100))
foreach (var file in inputFiles)
using (var input = (TiffImage)Image.Load(file))
output.AddFrame(TiffFrame.CreateFrameFrom(input.Frames[0], createOptions));
output.ActiveFrame = output.Frames[1];

Actually you are saying aren't TIFF images,but JPG files with incorrect TIFF extension.

How to find the give input files are in correct format or not ,is there any code in aspose to find that ,please send if any.

Thanks in advance.
Hi Aravind,

Thank you for your inquiry. You may use the following code snippet to get the file extension. Once it is confirmed that the loaded image has the desired extension that proceed further.

using (Aspose.Imaging.Image imageLoaded = Aspose.Imaging.Image.Load("sample.tiff"))