Image file types


I keep getting this error even after defining the file type.

Invalid image file type for image Parameter name: Unknown

I am trying to insert an image as a watermark, I have looked at the notes in Wiki but still no avale thanks for any help.


Thanks for considering Aspose.

Could u attach image file for our tests?


Aspose.Pdf gets image type from the extended file name. For example, image1.png will be considered as a PNG image. If your file name is not normal, please use ImageFileType to set the image file type.


Here you go I have used the filetype as well is still gives me an error too


Thanks for considering Aspose.

I have tried to make wartermark with your gif, everything works well. My test code is below:

Pdf pdf1 = new Pdf();

Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

Aspose.Pdf.Image image1 = new Aspose.Pdf.Image(sec1);

image1.ImageInfo.File = @"E:\NeedToTest\Complete.gif";
image1.ImageInfo.ImageFileType = ImageFileType.Gif;
Aspose.Pdf.GraphNote note1 = new GraphNote(sec1);
note1.Content = "this is note1";
note1.PositionX = 50;
note1.PositionY = 100;

Aspose.Pdf.Image image2 = new Aspose.Pdf.Image(sec1);

image2.ImageInfo.File = @"E:\NeedToTest\Complete.gif";
image2.ImageInfo.ImageFileType = ImageFileType.Gif;
image2.ImageInfo.CcittSubFormat = CcittSubFormat.Group31D;
image2.ImageWidth = 350;
image2.ImageHeight = 400;


I used Aspose.Pdf version


Thanks Tommy and Kevin